Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Microsoft winsdkfb Not Logged In: You are not logged in. Please login and try again. C# WinRT

For our new Windows 10 application (C# + XAML) we are using the new https://github.com/Microsoft/winsdkfb/ login, however since we have migrated to this login I am having no luck with facebook login.

We are using FBResult result = await sess.LoginAsync(permissions); and I am getting this error all the time: "Not Logged In: You are not logged in. Please login and try again."

enter image description here

My code is litteraly a copy and paste from the samples they did on github: I have checked my SID and FacebookAppId and they are the same on both the app and the Facebook website.

public async Task<string> LogIntoFacebook()
        {
            //getting application Id
            string SID = WebAuthenticationBroker.GetCurrentApplicationCallbackUri().ToString();

            //// Get active session
            FBSession sess = FBSession.ActiveSession;
            sess.FBAppId = FacebookAppId;
            sess.WinAppId =  SID;

            //setting Permissions
            FBPermissions permissions = new FBPermissions(PermissionList);

            try
            {
                // Login to Facebook
                FBResult result = await sess.LoginAsync(permissions);

                if (result.Succeeded)
                {
                    // Login successful
                    return sess.AccessTokenData.AccessToken;
                }
                else
                {
                    // Login failed
                    return null;
                }
            }
            catch (InvalidOperationException ex)
            {
                SimpleIoc.Default.GetInstance<IErrorService>().ReportErrorInternalOnly(ex);
                return null;
            }
            catch (Exception ex)
            {
                SimpleIoc.Default.GetInstance<IErrorService>().ReportErrorInternalOnly(ex);
                return null;
            }

            return null;
        }

by doing this:

//getting application Id
string SID = WebAuthenticationBroker.GetCurrentApplicationCallbackUri().ToString();

it is generating me an SID that looks like this: ms-app://s-1-15-2-0000-bla-bla-bla-667/ so I tried adding ms-app:// to the facebook developer settings page but it did not want it, so I tried removing ms-app:// from the SID when passing it to WinAppId but still no luck

enter image description here

I have filled the field Windows Store SID wih My FBAppId : enter image description here

does anyone have this issue?

Edit 1: My code is copy and paste from here: http://microsoft.github.io/winsdkfb/

Edit2: playing the samples from Microsoft my issues is coming from my Application Id. I did follow step 6: (Enable OAuth login)

  • Select the created app on developers.facebook.com.
  • Click “Settings” from the menu on the left.
  • Click on the “Advanced” tab.
  • Under the “OAuth Settings” section, enable “Client OAuth Login” and “Embedded browser OAuth Login”.
  • Click on “Save Changes”.
like image 861
Damien Avatar asked Feb 01 '16 19:02

Damien


1 Answers

After trying everything and NOT wanting to use WebAuthentificationBroker I have found the solution.

Go on the Facebook Developer website: https://developers.facebook.com

Then:

Go to your app name -> Settings -> Advance:

Under: Valid OAuth redirect URIs you need to add: https://www.facebook.com/connect/login_success.html

Save and you are good to go now! enter image description here

like image 189
Damien Avatar answered Oct 30 '22 19:10

Damien