使用 OAuth2.0 Playground 进行测试

Posted

技术标签:

【中文标题】使用 OAuth2.0 Playground 进行测试【英文标题】:Using OAuth2.0 Playground for testing 【发布时间】:2017-02-18 17:20:57 【问题描述】:

我想测试一些来自 Proximity Beacon API 的 API 请求。所以我按照this site 的步骤,将测试重定向网址(https://developers.google.com/oauthplayground)放入OAuth-2.0-Client-ID。当我尝试从操场发出请求时,我得到以下输出:


  "error": 
    "status": "PERMISSION_DENIED", 
    "message": "Google Proximity Beacon API has not been used in project google.com:oauth-2-playground before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/proximitybeacon.googleapis.com/overview?project=google.com:oauth-2-playground then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.", 
    "code": 403, 
    "details": [
      
        "@type": "type.googleapis.com/google.rpc.Help", 
        "links": [
          
            "url": "https://console.developers.google.com/apis/api/proximitybeacon.googleapis.com/overview?project=google.com:oauth-2-playground", 
            "description": "Google developers console API activation"
          
        ]
      
    ]
  

显然它使用了错误的项目,但我只到了一个步骤,我可以选择我的帐户,但不能选择我的项目。我检查了两次,我唯一的猜测是我不能使用这个redirect_url。

所以我的问题是:为什么要尝试使用 google.com:oauth-2-playground 项目而不是我的项目?我该如何改变呢?

【问题讨论】:

你不能把它变成谷歌的东西,他们需要改变它。不过,我不知道他们什么时候会修复它。 我投票决定将此问题作为题外话结束,因为它与 Google Oauth Playground 的一个错误/使用有关,它不是除 google 之外的任何人都可以修复的错误。 好的,谢谢。我已经认为它一定是一个错误。 【参考方案1】:

没有在 OAuth 2.0 Playground 使用的默认凭据上启用 Proximity Beacon API。我刚刚启用了该 API,现在应该可以使用了。

或者,您可以在 Playground 的配置菜单中设置 OAuth 2.0 Playground 以使用您自己应用的 OAuth 凭据(客户端 ID 和客户端密码)。

【讨论】:

我启用了 api,但还是得到了那个错误。我的测试解决方案是使用服务器端设置和我的 client-id 和 secret 谷歌云控制台中缺少 Proximity Beacon API。有人可以确认一下吗?

以上是关于使用 OAuth2.0 Playground 进行测试的主要内容,如果未能解决你的问题,请参考以下文章

OAuth 2.0 游乐场:未授权客户端

oAuth 2.0 游乐场

Oauth2.0详解及安全使用

OAUTH2.0基础概念篇

如何使用 Twisted 通过 OAuth2.0 身份验证检查 Gmail

OAuth2.0 - 它如何防止客户端冒充?