gpt4 book ai didi

swift - 使用 YouTube API (Swift) 对 YouTube 视频进行评分

转载 作者:行者123 更新时间:2023-11-30 12:07:09 26 4
gpt4 key购买 nike

我希望能够通过在我的 iOS 应用中使用 YouTube API 来点赞 YouTube 视频。我正在使用 Alamofire 来触发请求,如下所示:

Alamofire.request("https://www.googleapis.com/youtube/v3/videos/rate", parameters: ["id":VIDEO_ID,"rating":"like","key":API_KEY], encoding: URLEncoding.default, headers: nil)

但这不起作用,因为 API 需要授权。我正在浏览YouTube的references试图弄清楚如何获得授权,但我不明白它,因为我对使用 API 和 OAuth 2.0 协议(protocol)不太熟悉。有人可以帮我完成这件事吗?我将不胜感激!非常感谢!

最佳答案

遵循 Implementing OAuth 2.0 Authorization 中的 Youtube API OAuth 指南。您可以看到不同的 Oauth 流程:

OAuth 2.0 流程

Google APIs support several OAuth 2.0 use cases:

  • The server-side flow supports web applications that can securely store persistent information.
  • The client-side flow supports JavaScript applications running in a browser.
  • The installed application flow supports applications installed on a device, such as a phone or computer. The device flow supports devices with limited input capabilities, such as game consoles and video cameras.
  • The service account flow supports server-to-server interactions that do not access user information. However, the YouTube Data API does not support this flow. Since there is no way to link a Service Account to a YouTube account, attempts to authorize requests with this flow will generate a NoLinkedYouTubeAccount error.

还有Swift Youtube Quickstart供您引用。

关于swift - 使用 YouTube API (Swift) 对 YouTube 视频进行评分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46548734/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com