【问题标题】:Google Developer API keys & YouTube APIGoogle Developer API 密钥和 YouTube API
【发布时间】:2014-01-25 18:01:33
【问题描述】:

我使用 YouTube 开始了一个基于 Web 的开发项目,当我注册 API 时,我收到的只是一个客户端 ID 和电子邮件 ID。然而,在调用数据 API 的 Ruby 示例文本中,它指出:

  def initialize(scope)
    credentials = Google::APIClient::ClientSecrets.load
    @authorization = Signet::OAuth2::Client.new(
      :authorization_uri => credentials.authorization_uri,
      :token_credential_uri => credentials.token_credential_uri,
      :client_id => credentials.client_id,
      :client_secret => credentials.client_secret,
      :redirect_uri => credentials.redirect_uris.first,
      :scope => scope

我不知道去哪里获取这些凭据。想法?

【问题讨论】:

    标签: ruby api oauth youtube google-api


    【解决方案1】:

    由于 YouTube 现在是基于 Google 帐户的,因此需要通过 Google Developers Console(选择 YouTube 数据 API)获取这些凭据,并且您必须启动正常的 Google 登录过程。您的 client_id 和 client_secret 是在您在控制台上创建新应用程序时生成的,您的 redirect_uri 是根据您的应用程序结构设置的。

    虽然 Signet 有一个不错的 OAuth2 模块与之关联,但我发现 Omniauth 非常易于使用(您仍然可以将它与 Signet 结合使用)。如果您不需要自定义登录过程,Omniauth 会将其中大部分放在一个黑匣子中(它非常高接触),并为您处理令牌刷新等。我可能会使用Omniauth Google strategy 获取您的令牌,然后使用Google Ruby client 提出请求。

    【讨论】:

      猜你喜欢
      • 2017-01-25
      • 2013-09-09
      • 2021-11-16
      • 1970-01-01
      • 2018-03-04
      • 2014-03-20
      • 2018-03-12
      • 1970-01-01
      • 2012-03-18
      相关资源
      最近更新 更多