无效的OAuth访问令牌,使用应用程序访问令牌时,Android的 [英] Invalid OAUTH access token, when using an application access token, Android

查看:1043
本文介绍了无效的OAuth访问令牌,使用应用程序访问令牌时,Android的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如标题所说,当我试图要求获得与安装领域的好友列表:

As the title says, when I try to request to get the friends list with the field installed:

"me/friends?Fields=installed&access_token=..."

我碰到下面的错误在我的logcat:

I get the following error in my logcat:

"Invalid OAuth access token"

在Facebook上的API,我看到安装需要采取一个应用程序访问令牌期待。所以我使用产生使用的appid和应用秘密应用程序访问令牌:

When looking on the facebook api I see that installed needs to take an application access token. So I generated the application access token using the appId and app Secret using:

<一个href=\"https://graph.facebook.com/oauth/access_token?grant_type=client_credentials&client_id=APP_ID&client_secret=APP_SECRET\" rel=\"nofollow\">https://graph.facebook.com/oauth/access_token?grant_type=client_credentials&client_id=APP_ID&client_secret=APP_SECRET

下面是code:

try {

 JSONObject obj = Util.parseJson(mFacebook.request("me/friends?fields=installed&access_token=..."));

  Log.d("json Response", obj.toString());
  JSONArray array = obj.optJSONArray("data");
  if (array != null) {
                      for (int i = 0; i < array.length(); i++) {
                        //  String name = array.getJSONObject(i).getString("name");

                          String id = array.getJSONObject(i).getString("id");

                          Log.d("Friends: ",id);
                      }
                  } 
  }catch (Exception e){
    Log.d("Friends:", e.getMessage());
  }

任何一个任何想法,为什么它这样做,我一直在寻找的年龄。

Any one any ideas why its doing this I have been searching for ages.

干杯

推荐答案

你所认证后的应用程序访问令牌。

What you are getting after authentication is App Access Token.

报价:鉴定作为一个应用程序可以获取的访问令牌这使您可以要求代表一个应用程序的API的Facebook,而不是用户。这是有用的,例如修改应用程序的参数,创建和管理测试用户,或阅读应用程序的例如见解。应用程序访问令牌也可用于内容发布到Facebook的代表谁授予出版许可的应用程序的用户的

Facebook的文档。

您需要为您的情况下,什么是用户访问令牌。请参阅这个
用户需要进行身份验证并授予访问您的应用可以访问自己的好友列表中。

What you need for your case is an user access token. Refer this. A user needs to authenticate and grant access to your app for you have access to his friends list.

修改

有关检查单个用户的URL
https://graph.facebook.com/ {}的uid =领域的安装和放大器;的access_token =&LT; ACCESS_TOKEN>

For checking for a single user the url is https://graph.facebook.com/{uid}?fields=installed&access_token=< ACCESS_TOKEN >

您正试图获取用户好友列表,然后检查是否已安装的应用程序。我不认为让用户的好友列表,可以无需用户访问令牌。

You are trying to get user friend list and then check if the app is installed. I don't think getting user friend list is possible without user access token.

编辑2

从你的评论,你有FRIND的名单假设。那么你需要没有要求每个用户,而不是你可以使用FQL。

Assuming from your comment that you have the list of frind's. Then you need not call for each user instead you can use FQL.

https://graph.facebook.com/fql?q=SELECT UID,从用户is_app_user其中uid IN(UID1,UID2)

如果你有用户访问令牌,那么你就可以直接做的。

And if you have the user access token then you can directly do.

https://graph.facebook.com/fql?q=SELECT UID,从用户is_app_user其中uid IN(SELECT UID2从相知WHERE UID1 =我())

希望这会解决您的问题。

Hope this solves your problem.

这篇关于无效的OAuth访问令牌,使用应用程序访问令牌时,Android的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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