HybridAuth Twitter失败401 [英] HybridAuth Twitter Failure 401

查看:124
本文介绍了HybridAuth Twitter失败401的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题 我能够将HybridAuth库连接到Twitter,并且它停止工作.发布到Twitter帐户也可以.

THE PROBLEM I was able to connect to Twitter the the HybridAuth library, and it stopped working. Posting to a Twitter account was also functional.

我尝试过的内容 重置我的Twitter应用访问令牌. 创建一个全新的Twitter应用程序. 使用HybridAuth调试模式进行故障排除.

WHAT I HAVE TRIED Resetting my Twitter app access tokens. Creating an All new Twitter app. Using the HybridAuth debug mode to troubleshoot.

错误消息 验证失败.用户已取消验证或提供者拒绝了连接.

THE ERROR MESSAGE "Authentification failed. The user has canceled the authentication or the provider refused the connection.

原始错误消息:验证失败! Twitter返回了一个错误. 401未经授权."

Original error message: Authentification failed! Twitter returned an error. 401 Unauthorized."

我的研究 这似乎是由于缺少密钥和机密,但是我将这些设置在Twitter的配置文件中.

MY RESEARCH This seems to be attributed to the lack of the key and secret, but I set these in the Twitter config file.

代码

            $hybridauth = new Hybrid_Auth( $config );

            $adapter = $hybridauth->authenticate( "Twitter" );
            $hybridauth_session_data = $hybridauth->getSessionData();
            store_session_data($hybridauth_session_data);

            // get the user profile 
            $user_profile = $adapter->getUserProfile();

authenticate方法抛出异常.之前,它要求我允许通过该应用程序访问,现在它引发了错误.

The exception is being thrown by the authenticate method. Before it would ask me to allow access via the app and now it throws the error.

如果您需要更多信息,请告诉我. 里克

If you need more information, please let me know. Rick

推荐答案

所以这里是发生了什么,您应该知道的事情:

So HERE's what happened and what you should know:

  1. Twitter跟踪当前时间
  2. 如果API身份验证请求来自声称其时间不超过Twitter时间15分钟的服务器,则它将失败并显示401错误.


我如何解决它:

我使用 USNO主时钟将服务器时间设置为正确的时间.恰好偏移了15分钟.

I set my server time to the correct time by using the USNO Master Clock. It happened to be just over 15 minutes offset.

这篇关于HybridAuth Twitter失败401的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆