引用者null不匹配与API密钥上配置的引用者限制不匹配

时间:2016-06-22 21:13:43

标签: google-api

我已经设置了浏览器API密钥,并在referrer部分添加了“ .mydomain.com / ”。点击保存,等待5分钟。

执行和API调用时,我收到以下错误:

Array
(
    [error] => Array
        (
            [errors] => Array
                (
                    [0] => Array
                        (
                            [domain] => usageLimits
                            [reason] => ipRefererBlocked
                            [message] => The referrer null does not match does not match the referrer restrictions configured on your API key. Please use the API Console to update your key restrictions.
                            [extendedHelp] => https://console.developers.google.com/apis/credentials?project=xxxxxxxxx
                        )

                )

            [code] => 403
            [message] => The referrer null does not match does not match the referrer restrictions configured on your API key. Please use the API Console to update your key restrictions.
        )

)

如果我将引荐来源部分留在Google开发者控制台中,那么一切正常。我是否还需要在某处的代码中指定引荐来源?

使用https://github.com/yiisoft/yii2-httpclient拨打电话:

$path = 'https://www.googleapis.com/youtube/v3/channels';

$response = $this->client->createRequest()
    ->setMethod( 'get' )
    ->setUrl( $path )
    ->setData( [ 'key' => $this->key, 'part' => 'id', 'forUsername' => $user_handle ] )
    ->send();

发送:

GET https://www.googleapis.com/youtube/v3/channels?part=id&forUsername={USER_NAME}&key={YOUR_API_KEY}

该网站位于http://sub.mydomain.com

0 个答案:

没有答案