Forum Xamarin.iOS

How to solve invalid_grant and invalid_request issue in Microsoft authorisation using Xamarin.Auth?

sumitmishrasumitmishra Member ✭✭✭
edited March 6 in Xamarin.iOS

I am working on outlook rest Api for contact access in Xamarin.ios native app. I am using Xamarin.Auth library for authentication.
I have read Microsoft document for all setup like Azure Active Directory and configured as well. My iOS app open Microsoft authentication window but after entered login id and password it is sowing error as “one or more error: invalid_request and invalid_grant”.

Outlook Api reference link is:

Azure Active Directory:

Please check my code and help me to solve this issue.

        public override void ViewDidLoad()

                    AuthMsn = new OAuth2Authenticator(
                    clientId: "MyClientId",
                    scope: "",
                    authorizeUrl:  new Uri(""),
                    redirectUrl:  new Uri(""),
                    accessTokenUrl:  new Uri(""),

                    BeginInvokeOnMainThread(() =>
                        var viewController = AuthMsn.GetUI();
                        PresentViewController(viewController, true, null);
                    AuthMsn.Completed += AuthMsn_Completed;
                    AuthMsn.Error += AuthMsn_Error;

     private void AuthMsn_Completed(object sender, AuthenticatorCompletedEventArgs e)
                if (e.IsAuthenticated)

            private void AuthMsn_Error(object sender, AuthenticatorErrorEventArgs e)

                  var a=  e.Exception;



  • LandLuLandLu Member, Xamarin Team Xamurai

    Try to change the format of your redirectUrl:

  • sumitmishrasumitmishra Member ✭✭✭
    edited March 10

    Hi @LandLu ,
    I have changed redirectUrl but it is showing error before entering password and my earlier redirectUrl that is mention above is working good but it is calling AuthMsn_Error event with invalid_grant and invalid_request error. Please check screen shot

  • sumitmishrasumitmishra Member ✭✭✭

    can you please tell me how to pass these two parameter using Xamarin.Auth

    code:<Code received from the previous call to /authorize endpoint of AAD>
Sign In or Register to comment.