如何使用 ios 中的 google 访问令牌通过 api 访问我的 YouTube 频道?
How to access my youtube channel with api using my google access token in ios?
我想制作基于 youtube 频道的应用。我有 google 访问令牌,但我不知道如何使用我的访问令牌调用 youtube api 或如何传递参数。
这是我的代码:
NSString *newURL = [NSString stringWithFormat:@"googleapis.com/youtube/v3/…;, idToken];
如 Calling the YouTube Data API 中所述,在为用户获取访问令牌后,您的应用程序可以使用该令牌代表该用户提交授权的 API 请求。以下是指定访问令牌的两种支持方式。
- This first option provides greater security and is the recommended approach. Specify the access token as the value of the
Authorization: Bearer
HTTP request header:
`POST /feeds/api/users/default/uploads HTTP/1.1
Host: gdata.youtube.com
Authorization: Bearer ACCESS_TOKEN
...`
您可以通过以下命令使用 cURL 对此进行测试:
curl -H "Authorization: Bearer ACCESS_TOKEN" gdata.youtube.com/feeds/api/users/default/uploads
- Specify the access token as the value of the
access_token
query parameter:
https://gdata.youtube.com/feeds/api/users/default/uploads?access_token=ACCESS_TOKEN
您可以通过以下命令使用 cURL 对此进行测试:
curl gdata.youtube.com/feeds/api/users/default/uploads?access_token=YOUR_ACCESS_TOKEN
我想制作基于 youtube 频道的应用。我有 google 访问令牌,但我不知道如何使用我的访问令牌调用 youtube api 或如何传递参数。
这是我的代码:
NSString *newURL = [NSString stringWithFormat:@"googleapis.com/youtube/v3/…;, idToken];
如 Calling the YouTube Data API 中所述,在为用户获取访问令牌后,您的应用程序可以使用该令牌代表该用户提交授权的 API 请求。以下是指定访问令牌的两种支持方式。
- This first option provides greater security and is the recommended approach. Specify the access token as the value of the
Authorization: Bearer
HTTP request header:
`POST /feeds/api/users/default/uploads HTTP/1.1
Host: gdata.youtube.com
Authorization: Bearer ACCESS_TOKEN
...`
您可以通过以下命令使用 cURL 对此进行测试:
curl -H "Authorization: Bearer ACCESS_TOKEN" gdata.youtube.com/feeds/api/users/default/uploads
- Specify the access token as the value of the
access_token
query parameter:
https://gdata.youtube.com/feeds/api/users/default/uploads?access_token=ACCESS_TOKEN
您可以通过以下命令使用 cURL 对此进行测试:
curl gdata.youtube.com/feeds/api/users/default/uploads?access_token=YOUR_ACCESS_TOKEN