3

After reading the new Facebook Permissions API documentation (v2.0), I updated my Unity3D application to request for both public_profile and user_friends permissions instead of the recently deprecated basic_info one.

From:

FB.Login ("basic_info,publish_actions", LoginCallback);

To:

FB.Login ("public_profile,user_friends,publish_actions", LoginCallback);

Everything works fine inside both the Unity editor and the iOS build, but when executing the application on my Android device I can see the next error message printed to the Terminal:

W/fb4a(:<default>):BlueServiceQueue( 2275): Exception during service
W/fb4a(:<default>):BlueServiceQueue( 2275): com.facebook.http.protocol.ApiException: invalid permissions: public_profile
W/fb4a(:<default>):BlueServiceQueue( 2275):     at com.facebook.http.protocol.ApiResponseChecker.b(ApiResponseChecker.java:86)
W/fb4a(:<default>):BlueServiceQueue( 2275):     at com.facebook.http.protocol.ApiResponseChecker.a(ApiResponseChecker.java:139)
W/fb4a(:<default>):BlueServiceQueue( 2275):     at com.facebook.http.protocol.ApiResponse.g(ApiResponse.java:149)
W/fb4a(:<default>):BlueServiceQueue( 2275):     at com.facebook.platform.auth.server.GetPermissionsDescriptionMethod.a(GetPermissionsDescriptionMethod.java:135)
W/fb4a(:<default>):BlueServiceQueue( 2275):     at com.facebook.platform.auth.server.GetPermissionsDescriptionMethod.a(GetPermissionsDescriptionMethod.java:33)
W/fb4a(:<default>):BlueServiceQueue( 2275):     at com.facebook.http.protocol.ApiResponseHandler.a(ApiResponseHandler.java:59)
W/fb4a(:<default>):BlueServiceQueue( 2275):     at com.facebook.http.protocol.ApiResponseHandler.handleResponse(ApiResponseHandler.java:31)
W/fb4a(:<default>):BlueServiceQueue( 2275):     at com.facebook.http.common.FbHttpRequestProcessor.a(FbHttpRequestProcessor.java:312)
W/fb4a(:<default>):BlueServiceQueue( 2275):     at com.facebook.http.common.FbHttpRequestProcessor.a(FbHttpRequestProcessor.java:142)
W/fb4a(:<default>):BlueServiceQueue( 2275):     at com.facebook.http.common.FbHttpRequestProcessor.b(FbHttpRequestProcessor.java:98)
W/fb4a(:<default>):BlueServiceQueue( 2275):     at com.facebook.http.common.FbHttpRequestProcessor.a(FbHttpRequestProcessor.java:228)
W/fb4a(:<default>):BlueServiceQueue( 2275):     at com.facebook.http.protocol.SingleMethodRunnerImpl.a(SingleMethodRunnerImpl.java:415)
W/fb4a(:<default>):BlueServiceQueue( 2275):     at com.facebook.http.protocol.SingleMethodRunnerImpl.a(SingleMethodRunnerImpl.java:170)
W/fb4a(:<default>):BlueServiceQueue( 2275):     at com.facebook.http.protocol.AbstractSingleMethodRunner.a(AbstractSingleMethodRunner.java:18)
W/fb4a(:<default>):BlueServiceQueue( 2275):     at com.facebook.platform.auth.server.GetPermissionStringOperation.a(GetPermissionStringOperation.java:117)
W/fb4a(:<default>):BlueServiceQueue( 2275):     at com.facebook.platform.auth.server.GetPermissionStringOperation.a(GetPermissionStringOperation.java:81)
W/fb4a(:<default>):BlueServiceQueue( 2275):     at com.facebook.platform.auth.server.GetPermissionStringOperation.a(GetPermissionStringOperation.java:66)
W/fb4a(:<default>):BlueServiceQueue( 2275):     at com.facebook.platform.common.server.PlatformOperationHandler.a(PlatformOperationHandler.java:60)
W/fb4a(:<default>):BlueServiceQueue( 2275):     at com.facebook.fbservice.service.BlueServiceQueue.e(BlueServiceQueue.java:345)
W/fb4a(:<default>):BlueServiceQueue( 2275):     at com.facebook.fbservice.service.BlueServiceQueue.d(BlueServiceQueue.java:56)
W/fb4a(:<default>):BlueServiceQueue( 2275):     at com.facebook.fbservice.service.BlueServiceQueue$3.run(BlueServiceQueue.java:265)
W/fb4a(:<default>):BlueServiceQueue( 2275):     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
W/fb4a(:<default>):BlueServiceQueue( 2275):     at java.util.concurrent.FutureTask.run(FutureTask.java:237)
W/fb4a(:<default>):BlueServiceQueue( 2275):     at com.facebook.common.executors.ListenableScheduledFutureImpl.run(ListenableScheduledFutureImpl.java:59)
W/fb4a(:<default>):BlueServiceQueue( 2275):     at android.os.Handler.handleCallback(Handler.java:733)
W/fb4a(:<default>):BlueServiceQueue( 2275):     at android.os.Handler.dispatchMessage(Handler.java:95)
W/fb4a(:<default>):BlueServiceQueue( 2275):     at android.os.Looper.loop(Looper.java:146)
W/fb4a(:<default>):BlueServiceQueue( 2275):     at android.os.HandlerThread.run(HandlerThread.java:61)
W/fb4a(:<default>):GDPDialog( 2275): Failed to load
W/fb4a(:<default>):GDPDialog( 2275): com.facebook.fbservice.service.ServiceException: API_ERROR: API_ERROR
W/fb4a(:<default>):GDPDialog( 2275):    at com.facebook.fbservice.ops.BlueServiceOperation.c(BlueServiceOperation.java:639)
W/fb4a(:<default>):GDPDialog( 2275):    at com.facebook.fbservice.ops.BlueServiceOperation.c(BlueServiceOperation.java:47)
W/fb4a(:<default>):GDPDialog( 2275):    at com.facebook.fbservice.ops.BlueServiceOperation$2.run(BlueServiceOperation.java:604)
W/fb4a(:<default>):GDPDialog( 2275):    at android.os.Handler.handleCallback(Handler.java:733)
W/fb4a(:<default>):GDPDialog( 2275):    at android.os.Handler.dispatchMessage(Handler.java:95)
W/fb4a(:<default>):GDPDialog( 2275):    at android.os.Looper.loop(Looper.java:146)
W/fb4a(:<default>):GDPDialog( 2275):    at android.app.ActivityThread.main(ActivityThread.java:5487)
W/fb4a(:<default>):GDPDialog( 2275):    at java.lang.reflect.Method.invokeNative(Native Method)
W/fb4a(:<default>):GDPDialog( 2275):    at java.lang.reflect.Method.invoke(Method.java:515)
W/fb4a(:<default>):GDPDialog( 2275):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
W/fb4a(:<default>):GDPDialog( 2275):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
W/fb4a(:<default>):GDPDialog( 2275):    at dalvik.system.NativeStart.main(Native Method)

What does this error mean? How can I fix it?

I am using Unity v4.3.4f1 and the latests Facebook SDK v5.2.1 (FacebookSDK-140527.unitypackage).

Thanks in advance.

georgepiva
  • 874
  • 9
  • 29
  • Have you tried doing this with the previous Facebook SDK (5.1)? I've found a lot of bugs on this new release – Gaston Claret Jun 04 '14 at 20:51
  • Hi @GastonClaret. Yes. Actually I was using an old Facebook SDK the first time I saw this `ApiException` (v5.0.4 - FacebookSDK-140220-beta.unitypackage) and so I thought that updating it to its most recent version would fix the issue but no luck. – georgepiva Jun 04 '14 at 21:47
  • @GastonClaret Do you know if we must upgrade our apps in order to conform with the latest Permissions API (v2)? Did you find some documentation pointing how to migrate from API v1 to API v2? Thanks in advance. – georgepiva Jun 06 '14 at 16:55

4 Answers4

4

Had the similar issue - worked on iOS, but not Android. I have to change back to "basic_info" as part of the permission list, it works fine now.

Liangjun
  • 601
  • 4
  • 13
  • I think this hack doesn't work when your app is released to Google Play store (in production mode). – Liangjun Aug 09 '14 at 16:51
1

I had the same problem but in my case I need user's email and friend list. When requesting this info the public_profile is automatically added so maybe you can use this too.

Try using just "email, user_friends"

Fliperamma
  • 106
  • 8
0

In my case, problem was at devices, with FB application My workaround is disable authorization via FB application and use dialog only

 openRequest.setLoginBehavior(SessionLoginBehavior.SUPPRESS_SSO);
Dehimb
  • 252
  • 3
  • 15
0

Here are the two methods I use for this problem. Seems to work fine.

private void setPermissionNeededtoPost(){
if( CheckForApp("com.facebook.katana") )facebookappisinstalledonthisdevice = true;
    if(facebookappisinstalledonthisdevice){
        permissionNeededtoPost = "email,user_friends,publish_actions";
    }else{
        permissionNeededtoPost = "publish_actions";
    }
}

private bool CheckForApp(string appID)
{
    AndroidJavaClass up = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
    AndroidJavaObject ca = up.GetStatic<AndroidJavaObject>("currentActivity");
    AndroidJavaObject PackageManager = ca.Call<AndroidJavaObject>("getPackageManager");
    AndroidJavaObject list = PackageManager.Call<AndroidJavaObject>("getInstalledPackages",0);
    int num = list.Call<int>("size");
    for(int i = 0; i < num; i++)
    {
        AndroidJavaObject info = list.Call<AndroidJavaObject>("get", i);
        string appName = info.Get<string>("packageName");
        if(appName.CompareTo(appID) == 0)
        {
            return true;
        }
    }
    return false;
}