简体   繁体   English

Facebook SDK 3.0-其他权限

[英]Facebook SDK 3.0 - additional permissions

There is a task to provide for server-side Access Token with several permissions (several read and publish). 有一项任务是为服务器端访问令牌提供几种权限(多次读取和发布)。 In version 3.0 there are 2 separate methods for session open: openForRead and openForPublish. 在3.0版中,有2种单独的会话打开方法:openForRead和openForPublish。

At the beginning application is asking for read permissions: 在开始时,应用程序要求读取权限:

private void authorizeFacebook() {
    if (DEBUG)
        Log.d(TAG, "Facebook authorization");
    Session session = Session.getActiveSession();
    if (!session.isOpened() && !session.isClosed()) {
        session.openForRead(this.createReadRequest());
    } else {
        Session.openActiveSession(this, true, mFacebookSessionCallback);
    }
}

But after status callback, application asks for publish permission: 但是在状态回调之后,应用程序请求发布权限:

if (session.isOpened() && !session.getPermissions().contains("publish_stream")) {
    if (DEBUG)
        Log.d(TAG, "Facebook, Request additional permission: Publish Stream");

    session.requestNewPublishPermissions(new NewPermissionsRequest(this, Arrays.asList("publish_stream")).setCallback(mFacebookSessionCallback).setLoginBehavior(SessionLoginBehavior.SUPPRESS_SSO));

And there is a huge problem in user experience, because after additional permission request, facebook login form appear, and user must input credentials again... Does it work as designed by SDK developers?.. or am I doing something wrong? 用户体验中存在一个巨大的问题,因为在请求了额外的权限后,facebook登录表单出现了,并且用户必须再次输入凭据...它是否按SDK开发人员的设计工作?..还是我做错了什么?

Might be a late for this answer. 这个答案可能迟到了。 I had a similar problem, with the FB SDK 3.0 for Android. 对于Android版FB SDK 3.0,我遇到了类似的问题。 It was a bug in the SDK and they've fixed it in FB SDK 3.0.1 for Android released on the 20th of March. 这是SDK中的一个错误,他们已经在3月20日发布的Android FB SDK 3.0.1中对其进行了修复。 The change log mentions: 更改日志中提到:

The Web View Login dialog includes the token information for scenarios where new permissions are being requested. “ Web视图登录”对话框包含用于请求新权限的方案的令牌信息。 This avoids having the user having to enter their login credentials whenever new permissions are requested for a session. 这样避免了用户在每次会话请求新权限时都必须输入其登录凭据。

Try again after you upgrade. 升级后重试。 Grab the new SDK from here . 这里获取新的SDK。

I find that if the user does not have the Facebook app installed on their Android device then the log-in screen appears every time he/she is requested for additional permissions. 我发现如果用户未在其Android设备上安装Facebook应用程序,则每次要求他/她提供其他权限时,都会出现登录屏幕。 If the user does have the Facebook app installed on their device however, then I find that he/she is only required to confirm/disconfirm the additional permissions with a yes/no button click. 但是,如果用户确实在其设备上安装了Facebook应用程序,那么我发现他/她只需要单击“是/否”按钮来确认/取消确认其他权限。

Btw, I've put together a series of three short-ish articles explaining how to open a Facebook session, request additional permissions and so forth. 顺便说一句,我整理了三篇简短的文章,解释了如何打开Facebook会话,请求其他权限等等。 Here's the first. 这是第一个。

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

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