访问令牌有效,但我们收到 OAuthException: An active access token error [英] The Access Token is Valid but We get OAuthException: An active access token error

查看:19
本文介绍了访问令牌有效,但我们收到 OAuthException: An active access token error的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们已经为一个应用程序工作了大约 2 个月,一切都很顺利.我们在登录权限中使用 PHP SDK 和离线模式但是自从几天前在 Facebook api 中最近更改并删除离线模式之后,我们开始面临未捕获的 OAuthException:必须使用活动访问令牌来查询有关当前用户的信息"的问题.

主要问题是在我们的应用程序中工作一段时间后(大约 10 分钟)确实会发生这种情况,但同时当我们通过 此链接我们看到令牌仍然有效,另一方面 cookie 仍然存在并且它不会过期但我们收到此错误:未捕获的 OAuthException:必须使用活动访问令牌来查询有关当前用户的信息"

我已经访问过此链接我下载了最新版本,但它没有帮助任何人都可以帮助我们请问哪里可能出错?

<小时>

感谢回复,我觉得和 yacon 一样在我们处理的那一刻访问 facebook->api(/me) 时似乎有一个错误应用程序的某些部分带有 javascript,使用 javascript sdk 真的很头疼和 PhP sdk 一起使用

解决方案

你可以解决这个问题,只需在 getLoginUrl 之后将 accesstoken 存储到 session 变量中

<块引用>

$facebook->getLoginUrl(...)

然后每当你初始化 facebook

<前>$facebook = 新 Facebook(数组('appId' => Yii::app()->params['facebook_appId'],'秘密' => Yii::app()->params['facebook_appSecret'],));

从会话中获取访问令牌并使用 setAccessToken 设置它

<块引用>

$facebook->setAccessToken(Yii::app()->session['access_token']);

We've been working on an application for about 2 months, and everything was going perfectly. we were using PHP SDK and offline mode in permissions for login But since some days ago after recent changes in Facebook api and removing offline mode we started facing the problem of "Uncaught OAuthException: An active access token must be used to query information about the current user."

The main problem is that it does happen after a while working in our app (about 10 mins) but at the same time when we check the validity of the token via this link we see that the token is still valid on the other hand the cookie does still exist and it doesn't expire but we get this error : "Uncaught OAuthException: An active access token must be used to query information about the current user"

I've already visited this link and I downloaded the latest version but it didn't help could anyone help us please where might be making mistake?


Thanks for responses, I think same as yacon it seems there's a bug when accessing facebook->api(/me) at the moment we are handling some parts of the app with javascript which is a real headache to use javascript sdk and PhP sdk alongside with each other

解决方案

You can solve this simply store accesstoken to session variable after getLoginUrl

$facebook->getLoginUrl(...)

then whenever you initialize facebook

$facebook = new Facebook(array(
  'appId' => Yii::app()->params['facebook_appId'],
  'secret' => Yii::app()->params['facebook_appSecret'],
));

get the accesstoken from session and set it using setAccessToken

$facebook->setAccessToken(Yii::app()->session['access_token']);

这篇关于访问令牌有效,但我们收到 OAuthException: An active access token error的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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