谷歌-Oauth认证错误

5
当尝试使用Google OAuth登录时,出现以下错误:
I, [2014-04-23T10:08:24.349056 #4905]  INFO -- omniauth: (google_oauth2) Request phase initiated.

I, [2014-04-23T10:08:24.861288 #4905]  INFO -- omniauth: (google_oauth2) Request phase initiated.

I, [2014-04-23T10:08:28.637438 #4905]  INFO -- omniauth: (google_oauth2) Callback phase initiated.

E, [2014-04-23T10:08:30.207714 #4905] ERROR -- omniauth: (google_oauth2) Authentication failure! invalid_credentials: OAuth2::Error, {"errors"=>[{"domain"=>"usageLimits", "reason"=>"accessNotConfigured", "message"=>"Access Not Configured. Please use Google Developers Console to activate the API for your project."}], "code"=>403, "message"=>"Access Not Configured. Please use Google Developers Console to activate the API for your project."}: 

{

 "error": {

  "errors": [
   {
    "domain": "usageLimits",
    "reason": "accessNotConfigured",
    "message": "Access Not Configured. Please use Google Developers Console to activate the API for your project."
   }
  ],

  "code": 403,
  "message": "Access Not Configured. Please use Google Developers Console to activate the API for your project."
 }
}
3个回答

7
答案在您的错误日志中,在您的帐户的开发者设置中激活Google API。

那该怎么链接呢? - Ryan Bigg
Google开发者控制台位于https://console.developers.google.com/project?authuser=0。 - aqn
应该启用哪个API?没有所谓的“Google API”,也没有关于“auth”或“credentials”的任何内容。 - Automatico
@Cort3z,你上面的评论有链接到登陆页面,在那里你可以授权给一个项目访问权限,类似于Facebook API。 - Babar
@Babar 是的。你还是没有回答这个问题。 - Automatico

6

我通过一些谷歌搜索找到了这个问题,但是我对@Babar的答案并不满意,因为它实际上没有解决我的问题。

经过大量挖掘,我发现您必须在开发者控制台中启用Google+ API有些人还说您需要Contacts API)。 我以前不必这样做,但显然有一些变化已经发生。

要这样做,请执行以下步骤:

  1. 转到https://console.developers.google.com/project
  2. 选择您的项目
  3. 从侧面板中选择“API和身份验证”
  4. 从下拉列表中选择“API”
  5. 查找并启用Google+ APIContacts API
  6. 启用它们后,等待约5分钟使API生效。

现在,您应该能够再次使用Oauth2登录。


这是一个更好的答案...谢谢,最终我已经让Devise与OAuth2配合工作了。 - Mi Ro

0

我也遇到了Rails应用程序抛出403错误的类似问题。所以我通过在终端中运行bundle update devise omniauth omniauth-google-oauth2来升级omniauth宝石,解决了这个问题。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接