2016-07-07 73 views

回答

1

为了您GET方法URI

https://www.googleapis.com/youtube/v3/channels?part=id%2CcontentDetails%2CcontentOwnerDetails&mine=true&key={YOUR_API_KEY} 

的JSON回应如下

{ 
    "error": { 
    "errors": [ 
     { 
     "domain": "youtube.parameter", 
     "reason": "authorizationRequired", 
     "message": "The request uses the <code>mine</code> parameter but is not properly authorized.", 
     "locationType": "parameter", 
     "location": "mine" 
     } 
    ], 
    "code": 401, 
    "message": "The request uses the <code>mine</code> parameter but is not properly authorized." 
    } 
} 

根据YouTube数据API - 错误

401(未经授权) - authorizationRequired - 请求使用矿山 参数,但没有正确授权。

参数值必须设置为true,指示API只返回被认证的用户所拥有的渠道。 (布尔)

推论:您没有授权从内容所有者,即YouTube频道所有者可能访问该频道的内容不准到您的应用程序的内容。

这是一个权限问题。 URI中的channelId在哪里?可能应该添加它。

+0

不,这不是权限问题。我被授权,这不是问题。我使用此页面(https://developers.google.com/youtube/v3/docs/channels/list#try-it)发出请求并给出了权限。请求是正确的,没有错误,所以没有认证的问题。我的问题是为什么contentOwnerDetails在响应中缺失?它包含在“零件”列表中。我需要contentOwnerDetails.contentOwner来获取用户的ID。 – micobg

1

如果您没有自己的渠道API不会返回contentOwnerDetails。由于您使用的是mine=true参数,因此您需要在API返回contentOwnerDetails之前先通过OAuth正确授权。请参阅https://developers.google.com/youtube/v3/guides/authentication

+0

如果我正确地忽略了“频道”API,它将返回授权用户拥有的频道列表(在“项目”属性中)。那么我怎么能看到他的Google user_id? – micobg

相关问题