Godaddy api 授权错误 [英] Godaddy api authorization error

查看:55
本文介绍了Godaddy api 授权错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试基于他们在此处提供的 API 为 GoDaddy 开发客户端应用程序https://developer.godaddy.com我有一个简单示例的问题,我正在尝试使用下一个 PHP 代码来检查域是否可用:

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();
}

而且我一直收到错误:客户端错误:401".我在使用 cURL 库时遇到了同样的问题.我没有找到任何在线支持.我需要帮助,有人可以解释我应该如何在他们的 api 服务上授权吗?也许我需要发送任何其他 http 标头或其他参数?

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?

推荐答案

密钥和秘密是您用于生产的密钥吗?当我完成这个过程时,默认情况下它会创建一个 TEST 密钥/秘密,我认为这是为了对抗 https://api.ote-godaddy.com

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

如果您使用的是生产密钥,请尝试通过以下命令手动执行 Curl 请求;类似:

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!

这篇关于Godaddy api 授权错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆