Forum Xamarin.Forms

Xamarin Auth re prompts user for permission after already granted

I have implemented the OAuth 2 authentication using Xamarin.Auth.

Authenticator = new OAuth2Authenticator(
clientId: OAuthConstants.CLIENT_ID,
clientSecret: null,
scope: OAuthConstants.SCOPE,
authorizeUrl: new Uri(OAuthConstants.AUTHORIZE_URL),
accessTokenUrl: new Uri(OAuthConstants.ACCESS_TOKEN_URL),
redirectUrl: new Uri(OAuthConstants.REDIRECT_URL),
getUsernameAsync: null,
isUsingNativeUI: true);

A user can signup using OAuth or use a local account and link that to a Google OAuth Account. Both these scenarios work fine.

When linking account or signing up the user is prompted to grant the scope permissions (profile email). I then get back the access token and use the Account Store to store the account.

Since this is now linked to google I store the google user if and a refresh token in the DB. The idea being is the app is uninstalled and the user then re-installs it I want them to be able to login again with oAuth.

This works - since I can find the user using the Google User Id but even thought the app ID has not changed when using the OAuth2Authenticator to request a access token I keeps asking the user to grant the permissions - even though they were already granted for the app.

Is there a different way to prompt them to login rather than just being asked for the permissions every time?

I am showing the presenter like follows:

var presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter();
CustomTabsConfiguration.CustomTabsClosingMessage = null;
presenter.Login(Authenticator);

Thanks,

Sign In or Register to comment.