简体   繁体   English

Facebook-错误代码-2500无效访问令牌

[英]Facebook - Error Code - 2500 Inactive Access Token

I am using Parse (by Facebook) as my back end services and I have linked Facebook with the existing Parse User. 我正在使用Parse(通过Facebook)作为我的后端服务,并且已经将Facebook与现有的Parse User链接在一起。

I am using the following code on an ParseUser linked with Facebook 我在与Facebook链接的ParseUser上使用以下代码

  accessToken = AccessToken.getCurrentAccessToken();
  Log.d("Access Token",accessToken.getToken());

   new GraphRequest(
            accessToken,"/me?fields=first_name,last_name",null,
            HttpMethod.GET,
            new GraphRequest.Callback(){

                public void onCompleted(GraphResponse graphResponse){

                    if(graphResponse.getError()!=null)
                        Log.d("Error", graphResponse.getError().toString());

                    else{
                        try{
                            JSONObject jsonObject = graphResponse.getJSONObject();
                            ParseUser user = ParseUser.getCurrentUser();

                            user.put("email",jsonObject.getString("email"));
                            user.saveInBackground();

                        }catch(JSONException e){
                            e.printStackTrace();
                        }
                    }
                }
            }
    ).executeAsync();

Now in my log I am getting an access token which when used at developers.facebook.com/tools/explorer/ -> It works completely fine there 现在在我的日志中,我得到了一个访问令牌,该令牌在developer.facebook.com/tools/explorer/上使用时->在此完全正常

In my log I am getting the following Error -> "{HttpStatus: 400, errorCode: 2500, errorType: OAuthException, errorMessage: An active access token must be used to query information about the current user.}" 在我的日志中,我得到以下错误 ->“ {HttpStatus:400,errorCode:2500,errorType:OAuthException,errorMessage:必须使用活动访问令牌来查询有关当前用户的信息。}”

This is totally frustrating. 这完全令人沮丧。 I am using the same token to access my information and it is working completely fine. 我正在使用相同的令牌来访问我的信息,并且它工作正常。

I tried something and it worked. 我尝试了一些方法,它奏效了。

Changed the following line 更改了以下行

 new GraphRequest(
        accessToken,"/me?fields=first_name,last_name",null,...

To

 Bundle bundle = new Bundle();
 bundle.putString("fields","first_name,last_name");
 new GraphRequest(
        accessToken,"/me",bundle,

And it worked ! 而且有效!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM