有一项任务是为服务器端访问令牌提供多种权限(多次读取和发布)。 在3.0版本中,会话打开有两种不同的方法:openForRead和openForPublish。
一开始,应用程序要求读取权限:
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); } }但是在状态回调之后,应用程序会要求发布权限:
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));并且用户体验存在巨大问题,因为在获得额外的权限请求后,会出现facebook登录表单,并且用户必须再次输入凭据...它是否像SDK开发人员设计的那样工作?或者我做错了什么?
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.
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?
最满意答案
这个答案可能会迟到。 我有一个类似的问题,使用适用于Android的FB SDK 3.0。 这是SDK中的一个错误,他们已经在3月20日发布的适用于Android的FB SDK 3.0.1中修复了它。 更改日志提到:
“Web视图登录”对话框包含正在请求新权限的方案的令牌信息。 这避免了每当请求会话的新权限时用户必须输入其登录凭证。
升级后再试一次。 从这里获取新的SDK。
Might be a late for this answer. I had a similar problem, with the FB SDK 3.0 for Android. 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. The change log mentions:
The Web View Login dialog includes the token information for scenarios where new permissions are being requested. 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.
更多推荐
session,权限,mFacebookSessionCallback,permission,openForRead,电脑培训,计算机培训,IT培训"
发布评论