回调为Android refreshCurrentAccessTokenAsync Facebook的Andr​​oid SDK中4.1+回调、refreshCurrentAccessTokenAsy

2023-09-07 17:20:38 作者:染陌

在Android的,我打电话 refreshCurrentAccessTokenAsync(),但似乎没有成为一个回调。我已经注册callbackManager调用之前 refreshCurrentAccessTokenAsync()和它永远不会被调用,而且也不 onActivityResult

In Android, I'm calling refreshCurrentAccessTokenAsync() but there doesn't appear to be a callback. I've registered callbackManager before invoking refreshCurrentAccessTokenAsync() and it never gets called, and neither does onActivityResult.

文档不要么说什么: 的https://developers.facebook.com/docs/reference/android/current/class/AccessToken/

Doc doesn't say anything either: https://developers.facebook.com/docs/reference/android/current/class/AccessToken/

在iOS的,有一个完成处理程序。

In iOS, there is a completion handler.

+ (void)refreshCurrentAccessToken:(FBSDKGraphRequestHandler)completionHandler;

什么是事件使用用户吊销其令牌或删除权限的最佳实践?

What is the best practice to use in the event a user revoked their token or removed permissions?

我想在IOS我会检查在 GraphRequest 完成处理,但看不到有什么在Android上推荐的方法,没有回调。

I assume on IOS I would check in the GraphRequest completion handler, but don't see what's the recommended way on Android with no callback.

谢谢!

推荐答案

您无法刷新该令牌,如果用户已撤销令牌。你只能刷新它,如果当前访问令牌仍然有效。

You cannot refresh the token if the user has revoked the token. You can only refresh it if the current access token is still valid.

该方法还调用图形API直接,这就是为什么没有onActivityResult被调用。

The method also calls Graph API directly, which is why there's no onActivityResult being called.

如果有一个成功的刷新,那么访问令牌将被更新,并可以使用AccessTokenTracker得到通知。

If there is a successful refresh, then the access token will be updated and you can use the AccessTokenTracker to get notifications.

最后,你为什么直接调用这个方法?通常情况下只使用图形API的SDK将自动刷新令牌你。

Lastly, why are you calling this method directly? Normally just by using the Graph API the SDK will refresh the token automatically for you.