2

Been trying to request for declined permission with FB.login("Scope") but it redirects me to the login page again. After logging in, it prompts me with a "You have already authorised APPNAME." FB.login doesn't support "auth_type".

Does anyone have any solutions to this problem?

Thanks~ May the force be with you

kreys
  • 987
  • 4
  • 21
  • I would suggest filing a bug at https://developers.facebook.com/bugs or see if it been reported there already – WizKid May 30 '14 at 08:56

1 Answers1

0

Not sure for which platform you've been trying to re-ask declined permissions, probably for Canvas. I can only suggest solution for Android.

First, we need to hack provided AndroidFacebook and FB classes. To prevent overriding of our changes with plugin update in the future, we almost don't touch third party files, just make classes partial:

// AndroidFacebook.cs

namespace Facebook
{
    sealed partial class AndroidFacebook : AbstractFacebook, IFacebook

// FB.cs

public sealed partial class FB : ScriptableObject

Now we can extend existing classes with a couple of methods:

using System.Collections.Generic;

namespace Facebook
{
    partial class AndroidFacebook
    {
        public void LoginWithParameters(IDictionary<string, object> parameters, FacebookDelegate callback = null)
        {
            if (parameters == null)
                parameters = new Dictionary<string, object>();
            var paramJson = MiniJSON.Json.Serialize(parameters);
            AddAuthDelegate(callback);
            CallFB("Login", paramJson);
        }
    }
}

partial class FB
{
    public static bool TryLoginWithParametersOnAndroid(IDictionary<string, object> parameters, Facebook.FacebookDelegate callback = null)
    {
        var androidFacebook = FacebookImpl as Facebook.AndroidFacebook;
        if (androidFacebook == null)
            return false;
        androidFacebook.LoginWithParameters(parameters, callback);
        return true;
    }
}

Here is how we can pass scope and auth_type:

var parameters = new Dictionary<string, object>
{
    { "scope", "email" },
    { "auth_type", "rerequest" },
};
var apiCallSucceeded = FB.TryLoginWithParametersOnAndroid(parameters, result =>
{
    ...
});
Viktor Pti
  • 319
  • 2
  • 13
  • Hey @Qbit, thanks for the workaround - unfortunately it doesn't work for us using Facebook's Unity SDK v6.0 - we simply see the login screen opened for a second and then immediately closed without asking again for the declined permissions. Do you have any clues to why this might happen? Thanks! – Ron Nov 03 '14 at 16:11