Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

How to user Refresh_Token for getting Access_Token

$
0
0

Hi,
We are using Xamarin.OAuth 2.0 for allowing user to login app using Identity provider, OAuth is working fine until getting Access_Token and Refresh_Token.
But we are not sure how to use Refresh_Token using OAuth sdk in order to get Access_Token .

public MyAccountAuthenticator(string clientId, string clientSecret, string scope, string redirectUrl, IMyAccountAuthenticationDelegate authenticationDelegate)
{
_authenticationDelegate = authenticationDelegate;

        _auth = new OAuth2Authenticator(clientId, clientSecret, "",
                                        new Uri(AuthorizeUrl),
                                        new Uri(redirectUrl),
                                        new Uri(AccessTokenUrl),
                                        null, IsUsingNativeUI);

        _auth.Completed += OnAuthenticationCompleted;
        _auth.Error += OnAuthenticationFailed;
    }

    public OAuth2Authenticator GetAuthenticator()
    {
        return _auth;
    }


    private void OnAuthenticationCompleted(object sender, AuthenticatorCompletedEventArgs e)
    {
        if (e.IsAuthenticated)
        {
            var token = new MyAccountOAuthToken
            {
                TokenType = e.Account.Properties["token_type"],                       
                AccessToken = e.Account.Properties["access_token"]
            };
            _authenticationDelegate.OnAuthenticationCompleted(token);
        }
        else
        {
            _authenticationDelegate.OnAuthenticationCanceled();
        }
    }

    private void OnAuthenticationFailed(object sender, AuthenticatorErrorEventArgs e)
    {
        _authenticationDelegate.OnAuthenticationFailed(e.Message, e.Exception);
    }

Thanks in advance.


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>