11

I am trying to develop client application for GoDaddy based on their API that they provide here https://developer.godaddy.com And I have a problem with simple example, I am trying to use the next PHP code to check if domain available:

use GuzzleHttp\Client;
try {
    $client = new Client([
        'base_uri' => 'https://api.godaddy.com',
    ]);

    $responce = $client->get(
        '/v1/domains/available?domain=example.guru',
        [
            'headers' => [
                'Authorization' => "sso-key $myKey:$mySecret",
                'X-Shopper-Id' => "$myID",
                'Accept' => 'application/json',
            ]
        ]
    );
    echo $responce->getBody();
} catch (Exception $e) {
    echo $e->getMessage();
}

And all the time I get error: "Client error: 401". Same problem I have with using cURL library. I didn't find any online support. I need help with it, can someone explain how I should authorize at their api service? Maybe I need to send any other http headers or additional params?

Adam
  • 16,089
  • 6
  • 66
  • 109
Network_SPY
  • 263
  • 1
  • 2
  • 9

3 Answers3

13

Are the key and secret you're using for production? When I go through the process, by default it creates a TEST key/secret, which I think are meant to go against https://api.ote-godaddy.com

If you are using production keys, try doing a manual Curl request from the command like; something like:

curl -H 'Authorization: sso-key {KEY}:{SECRET}' -H 'Content-Type: application/json' https://api.godaddy.com/v1/domains/available?domain=example.guru'

Let us know how it works out!

Brian Clifton
  • 691
  • 7
  • 14
  • 1
    Oh! I was using TEST key/secret which I've got by default. Yes, you're right, I've changed url to api.ote-godaddy.com and now it works well. Thank you for help – Network_SPY Aug 30 '15 at 12:41
  • How can i install oAuth in GoDaddy VPS server? @Brain – Gem Oct 25 '18 at 12:14
  • @Rathinam this issue is covering the now discontinued GoDaddy Cloud Servers product. With a VPS, all of that configuration is up to you (and I'm not too familiar with it unfortunately) :( – Brian Clifton Oct 27 '18 at 16:28
  • 1
    Thank you, I installed oauth using Google. – Gem Oct 27 '18 at 16:32
6

The problem was that I was using TEST {KEY}:{SECRET} and set wrong URL.

For the test {KEY}:{SECRET} URL has to be: https://api.ote-godaddy.com.

Also the method for checking domain availability (/v1/domains/available) doesn't need parameter 'X-Shopper-Id' in header. It works well without it. With parameter X-Shopper-Id request returns error "NOT_FOUND: The specified shopperId could not be found"(but it's other problem, maybe I didn't activate some option)

So if to take into account all changes, the working code for checking domain availability with test key/secret should be like this:

use GuzzleHttp\Client;
try {
    $client = new Client([
        'base_uri' => 'https://api.ote-godaddy.com'
    ]);

    $responce = $client->get(
        '/v1/domains/available?domain=example.guru',
        [
            'headers' => [
                'Authorization' => "sso-key $myKey:$mySecret",
                'Accept' => 'application/json',
            ]
        ]
    );
    echo $responce->getBody();
} catch (Exception $e) {
    echo $e->getMessage();
}
Network_SPY
  • 263
  • 1
  • 2
  • 9
  • Awesome, thanks for posting your code snippets! Really glad that you got it sorted out :) – Brian Clifton Aug 30 '15 at 16:44
  • Is any sandbox available for godaddy where i can test my api calls using test api key.Godaddy providing test api key but thats not working for me as well whenever i tried to purchase domain using api call. – arvind Aug 12 '17 at 11:40
0

I am using php and curl.

$domain = "jaisinghverma.com";<br>
$apiURL = 'https://api.ote-godaddy.com/v1/domains/available?
domain='.$domain.'&checkType=FULL&forTransfer=false';<br>
$headers = array(
  'Accept: application/json',
  'Authorization: sso-key ?????????',
);<br>
$ch = curl_init();<br>
curl_setopt($ch, CURLOPT_URL, $apiURL);<br>
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);<br>
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);<br>
$server_output = curl_exec ($ch);<br>
curl_close ($ch);<br>
print_r(json_decode($server_output));

above code is working fine for me.

Nuclear - Core
  • 159
  • 1
  • 2
  • 9