我想安装验证与谷歌加使用their tutorial。我按照方向逐字,改变了signin.php
中的client id
和client secret
。为了记录,Google开发者控制台中启用了Google plus API。我按照说明更新文件权限(chmod +x signin.php
和chmod -R 555 vendor/
)。然而,在加载我的身份验证URL(恰好在我的域的auth_test/
子目录中,然后单击登录按钮时,控制台会抛出401 (unauthorized)
,发送get
请求/activites.
我已经研究了该问题,并且看到这可能是由无效的令牌造成的,但我没有看到怎么说可能是因为一切都已经设置在singin.php.
太大的帮助,将不胜感激......谷歌加OAuth PHP 401(未授权)
1
A
回答
1
您需要重置您的应用程序的状态,如果断开刷新$tocken
。
Google API office处理API错误的文档
401: Invalid Credentials
授权标头无效。您使用的访问令牌为 已过期或无效。
{ "error": {
> "errors": [
> {
> "domain": "global",
> "reason": "authError",
> "message": "Invalid Credentials",
> "locationType": "header",
> "location": "Authorization",
> }
> ],
> "code": 401,
> "message": "Invalid Credentials" } }
建议的操作:刷新使用长寿命 刷新令牌的访问令牌。如果失败,如授权您的应用程序
而且它显然是在singin.php注释行没有说明通过OAuth的流程, 引导用户。 98:
// Normally the state would be a one-time use token, however in our // simple case, we want a user to be able to connect and disconnect // without reloading the page. Thus, for demonstration, we don't // implement this best practice. //$app['session']->set('state', '');
因此,在你的情况看来,您的应用程序是断开,从而导致$token
变空。因此强制这个代码块在行号:91
if (empty($token)) {
// Ensure that this is no request forgery going on, and that the user
// sending us this connect request is the user that was supposed to.
if ($request->get('state') != ($app['session']->get('state'))) {
return new Response('Invalid state parameter', 401);
}
相关问题
- 1. .NET HttpWebRequest oAuth 401未授权
- 2. Oauth,Twitter,401未授权
- 3. 谷歌oauth失败与401未经授权在rails omniauth
- 4. 谷歌的OAuth 2.0 invalid_client未经授权
- 5. Ominauth-的Evernote,的OAuth ::使用了未经授权401未授权
- 6. 401未授权使用雅虎的OAuth
- 7. twitter未授权401 c#oauth/request_token
- 8. QuickBooks的OAuth的API(401)未经授权
- 9. 401未经授权的foursquare OAuth
- 10. 401未经授权使用oauth-python-twitter
- 11. 401未授权
- 12. 谷歌联系人API:未经授权的401未知授权标头
- 13. 谷歌的任务验证与2条腿OAuth错误:401未授权
- 14. HTTP错误401:未授权
- 15. com.google.api.client.auth.oauth2.TokenResponseException:401未经授权
- 16. GCM 401未授权
- 17. httpResponse 401未授权
- 18. Exchange 401未授权
- 19. WGET 401未授权
- 20. botframework 401未授权
- 21. ReportViewer - 401:未授权
- 22. TokenResponseException:401未授权
- 23. 如何重置谷歌oauth 2.0授权?
- 24. Jira Oauth:401在PHP中未经授权oauth_problem =“signature_invalid”
- 25. 无法从谷歌Analytics的数据(401未经授权)
- 26. asp.net C#谷歌API的文档 - 401未授权
- 27. 401(未经授权)DotNetOpenAuth和谷歌日历错误
- 28. 谷歌联系API 401错误RestClient ::未授权
- 29. 401未经授权使用谷歌任务
- 30. TokenResponseException:401未授权当试图访问谷歌联系人Api
你确定你可以做一个curl请求?....也许你没有curl扩展启用。 – Hackerman