Forum Xamarin.Forms

Microsoft Graph or Microsoft Auth on Xamarin Forms in order to get access to MS account

Hello,
I don’t know if it has changed or I’m very stupid, because I don’t get the authentication with MS Account on Xamarin forms. On my native uwp app, I’m use the OneDrive SDK that use Graph SDK in order to do the authentication and sync a file. And I was very easy. Now I want to do the same on my Xamarin Forms app (for Android and ios) but I don’t get it. I started with Graph, I don’t get nothing, after I found this thread https://forums.xamarin.com/discussion/66039/sample-for-using-microsoft-account-as-an-identity-provider-using-the-xamarin-auth and other blogs about Xamarin.Auth, I tried and nothing, I can’t get the webview works. And then I found a recent blog and code about graph https://github.com/mayur-tendulkar/XamarinDrive
And sample doesn’t work but I have integrated the code and start the authentication on my app. But When I accept the permission, app go back to my home page but it doesn’t return the user authorization object. So what thing am I doing incorrectly?
What have I done?
-I have created the app on my dashboard in order to get ID
-I have add Graph and identity with last version
-I have created the code as app in order to request the access and get the name of user.
-I have added the redirection url to app and dashboard.
What other thing have I to do in order to work?
Thank you

Best Answer

  • Cansado2930Cansado2930 ESMember ✭✭
    Accepted Answer

    I have found the fail, there was a problem with method OnActivityResult on mainactivity. so it return to app but it couldn't get the access.
    And I have other question, when I close app, then it requests to login on MS Account again. With Azure Mobile App, I can save the token and user id (with secure storage plugin) and then it doesn't request Access to account again. With MS Graph, Could I do same? If I save the token, can it login again without it requests again?
    Thank you!!

Answers

  • Cansado2930Cansado2930 ESMember ✭✭
    Accepted Answer

    I have found the fail, there was a problem with method OnActivityResult on mainactivity. so it return to app but it couldn't get the access.
    And I have other question, when I close app, then it requests to login on MS Account again. With Azure Mobile App, I can save the token and user id (with secure storage plugin) and then it doesn't request Access to account again. With MS Graph, Could I do same? If I save the token, can it login again without it requests again?
    Thank you!!

  • Cansado2930Cansado2930 ESMember ✭✭

    I didn't see it between deploys. It saves automatically the sesión and then it doesn't require to login again.

  • mirkarammirkaram Member ✭✭

    @Cansado2930 said:
    I have found the fail, there was a problem with method OnActivityResult on mainactivity. so it return to app but it couldn't get the access.
    And I have other question, when I close app, then it requests to login on MS Account again. With Azure Mobile App, I can save the token and user id (with secure storage plugin) and then it doesn't request Access to account again. With MS Graph, Could I do same? If I save the token, can it login again without it requests again?
    Thank you!!

    Bro I have the same problem like that, After granting app access in webview and on returning to app , the OnResultActivity has null intent

    Microsoft.Identity.Client.AuthenticationContinuationHelper.SetAuthenticationContinuationEventArgs(requestCode, resultCode, inent);

    @Cansado2930 how did you resolve this problem

  • Cansado2930Cansado2930 ESMember ✭✭

    I'm using the code of sample and instructions of MSAL project of here: https://github.com/AzureAD/microsoft-authentication-library-for-dotnet
    Tell me if you have been to build your sample.

Sign In or Register to comment.