如何在App Engine身份验证器中获取Facebook访问令牌

时间:2016-07-01 19:35:19

标签: java google-app-engine facebook-graph-api

在Google App Engine自定义Authenticator中,谷歌访问令牌收到

  String accessToken = req.getHeader("Authorization")

然而,为了检索facebook访问令牌,我尝试了一些选项,但没有成功。

  String code = req.getParameter("code");
  String code = req.getParameter("access_token");

请告诉我如何检索Facebook访问令牌。

1 个答案:

答案 0 :(得分:0)

的Android

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    FacebookSdk.sdkInitialize(this.getApplicationContext());
    accessToken = AccessToken.getCurrentAccessToken();
}

的iOS

- (void)viewDidLoad
{
  [super viewDidLoad];
  NSString *accessToken = [FBSDKAccessToken currentAccessToken];
}

JavaScript(Web)

FB.getLoginStatus(function(response) {
  if (response.status === 'connected') {
    var accessToken = response.authResponse.accessToken;
  } 
} );