Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

ProviderError #238

Open
FrancoisM opened this issue Apr 27, 2017 · 13 comments
Open

ProviderError #238

FrancoisM opened this issue Apr 27, 2017 · 13 comments

Comments

@FrancoisM
Copy link

I'm using the Win10 Nuget package (0.13).
Login fails with "ProviderError". Can't find anything about it.
All ids and redirect paths are ok.

@adiviness
Copy link
Contributor

adiviness commented Apr 27, 2017

Can you post your code that's calling LoginAsync, or a screenshot of the error or something? what language are you using the sdk from? Is the error coming from an exception or is it shown in a webview or something? This is too vague to be actionable for me currently.

@FrancoisM
Copy link
Author

Sure. Note that it used to work and I didn't change the code so maybe it is facebook setttings?
AppId, WinAppId, domain and callback are exactly the same as in FB. My app is in the store (and you can login with facebook). It's when I now run it from VS that I get the error.

result.Succeeded is false and errorInfo says ProviderError.

public static void Init()
        {
            var sess = FBSession.ActiveSession;
            sess.FBAppId = "xxxxxxxx";
            sess.WinAppId = "s-1-15-2-xxxxxxxxxxxxxxxxxxx";
            sess.SetWebViewRedirectUrl("https://xxxxxx.com", "/.auth/login/facebook/callback");
        }
public async Task LoginAsync(AuthenticationProvider loginProvider, IMobileServiceClient mobileServiceClient)
        {
            var sess = FBSession.ActiveSession;
            var permissions = new FBPermissions(new[] { "public_profile", "email", "user_friends" });
            var coreWindow = Windows.ApplicationModel.Core.CoreApplication.MainView;
            var dispatcher = coreWindow.CoreWindow.Dispatcher;
            var tcs = new TaskCompletionSource<object>();
            await dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () =>
            {
                try
                {
                    var result = await sess.LoginAsync(permissions);
                    if (!result.Succeeded) throw new Exception(result.ErrorInfo.ToString());
                    var token = sess.AccessTokenData.AccessToken;
                    var jToken = new JObject { { "access_token", token } };
                    await mobileServiceClient.LoginAsync(Helper.ConvertAuthenticationEnum(loginProvider), jToken);
                    tcs.SetResult(null);
                }
                catch (Exception ex)
                {
                    tcs.SetException(ex);
                }
            });
            await tcs.Task;
        }

@adiviness
Copy link
Contributor

So for Windows 10 LoginAsync will try to log in first with a WebAccountProvider if one is present, but as far as I know there really isn't one that exists for Facebook. My suggestion would be to create a little test application that calls WebAuthenticationCoreManager::FindAccountProviderAsync() for "https://www.facebook.com" and see if it returns a valid WebAccountProvider.

To get around the logic in LoginAsync that messes with providers you can pass a SessionLoginBehavior value to LoginAsync. I would see if that fixes the problem for you.

Are you sure though that it's our LoginAsync method that's causing the problem and not the other one in your try block? It seems to have more to do with stuff named provider, and the error is a ProviderError. I do know that a WebTokenRequestStatus has something to do with ProviderError if you're looking for more information on it.

@tarikdedic
Copy link

I have the same problem on my local machine (PC) but not on Mobile emulator (10.0.14393.0 720p 5 inch 1GB).
FBerror from LoginAsync result:

Code: 5001
ErrorUserMessage: ''
ErrorUserTitle: ''
Message: ProviderError
Subcode: 0
Type: WebTokenRequestStatus Error

@mszh
Copy link

mszh commented May 2, 2017

Have the same issue. Reproduced only with installed Facebook App. Without it - all work correctly

@adiviness
Copy link
Contributor

So I've been able to repro this issue, it appears that there's something wrong with the interaction between the sdk and the Facebook app. A workaround for now is to pass a SessionLoginBehavior to LoginAsync. SessionLoginBehavior::WebView or SessionLoginBehavior::WebAuth are probably the ones you'll want to use.

@Hanzalah-Adalan
Copy link

same here.. I realize that Facebook has changed my App Id on the app settings page.. and yet after I renew the Facebook app Id in my UWP app, the LoginAsync still throws the error:

Code: 5001
ErrorUserMessage: ''
ErrorUserTitle: ''
Message: ProviderError
Subcode: 0
Type: WebTokenRequestStatus Error

@Obg1
Copy link

Obg1 commented Aug 17, 2017

Same problem here, anyone have a fix to it?

@Obg1
Copy link

Obg1 commented Aug 17, 2017

I've manged to work around the error using:
create_task(sess->LoginAsync(permissions, winsdkfb::SessionLoginBehavior::WebView)).then([=](FBResult^ result)

@JLLLinn
Copy link

JLLLinn commented Sep 26, 2017

In FBSession::FBResultFromTokenRequestResult, would it make sense to just return ErrorCodeWebAccountProviderNotFound? Is the error caused by provider not found?

@sidgo28
Copy link

sidgo28 commented Feb 14, 2018

Same here :(. And that SessionLoginBehavior workaround doesn't work for me :(.

@adiviness
Copy link
Contributor

@sidgo28 can you share some more information about how you're experiencing the problem? Windows version, winsdkfb version, etc. specifying the SessionLoginBehavior works fine for me.

@sidgo28
Copy link

sidgo28 commented Feb 15, 2018

@adiviness
Windows version: Windows 10, Version 1709, Build 16299.248
winsdkfb version: 0.14.20170809.2

  • If the FB UWP app is not installed, it works without any problem.

  • If the FB app is installed:

  1. Using LoginAsync(permissions) results to:

ErrorInfo with code: 5001, message: "ProviderError", type: "WebTokenRequestStatus Error"

  1. Using LoginAsync(permissions, SessionLoginBehavior.WebView) results to a VS error:

Unhandled exception at 0x0F66F3F3 (winsdkfb.dll) in OneKeep.exe: 0xC0000005: Access violation reading location 0x00000000.

  1. Using LoginAsync(permissions, SessionLoginBehavior.WebView) and putting a breakpoint in the await LoginAsync line then manually stepping over to the next line results to (after some delay due to the await) no VS error but inconsistent results:

Oftentimes, ErrorInfo with code: 0, message: "unable to receive response", type: "HTTP request failed"

Sometimes, the login randomly succeeds without any error.

  1. Using LoginAsync(permissions, SessionLoginBehavior.WebView) and using the app outside VS then pressing the login button results to somewhat like Need to add a method on FBSession to re-request permissions. #3:

Sometimes app freeze then crash. Sometimes it shows the login dialog.

Here's the FBSession object in #3 and #4:
APIMajorVersion: 2
APIMinorVersion: 6
Redirect domain: "https://www.facebook.com"
Redirect path: "/connect/login_success.html"

And here's my code:

In the app constructor:

var sess = FBSession.ActiveSession;
sess.WinAppId = A.WinStoreId;
sess.FBAppId = A.FacebookAppId;

On login button tapped:

var sess = FBSession.ActiveSession;
var permissions = new FBPermissions(requestedPermissions);
var result = await sess.LoginAsync(permissions, SessionLoginBehavior.WebView) ;
if (result.Succeeded) {
    cred = Credentials.Facebook(sess.AccessTokenData.AccessToken); // I'm using realm
    username = sess.User.Name;
}
else {
    page.Toast("Failed to login with Facebook.");
    return;
}

Also, I tried the other SessionLoginBehaviors but to no avail.
Thank you.

Edit:

After experimenting with the app, I think this has something to do with logging out the user.

Here's what I did:

  1. If I login after a fresh app launch, the login succeeds.

  2. But if I then logout then try to login again, the error comes out (whether I wait for some time before relogging-in or not). However, after the crash and launching the app again, the login succeeds just like in FileNotFoundException was unhandled by user code #1.

Hence, I do think that the issue is in the LogoutAsync method or in FacebookDialog.

Also here's my logout button onTapped code:

page.Toast("Logging out");
var sess = FBSession.ActiveSession;
if(sess.LoggedIn)
    await sess.LogoutAsync();
await User.Current.LogOutAsync(); // logout in realm
// todo: logout google
page.Toast("Logged out");
page.OnUserChanged(false, "");
Pivot.SelectedIndex = 0;

So do you think there's a temporary workaround for this? Thanks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants