# Xamarin - Using Refresh Token

**URL:** <https://community.auth0.com/t/xamarin-using-refresh-token/22104>\
**Category:** Get Help\
**Created:** [March 5, 2019, 4:09am UTC](https://community.auth0.com/t/xamarin-using-refresh-token/22104 "2019-03-05T04:09:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnnyjohnny](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/johnnyjohnny/32/12921_2.png) [@johnnyjohnny](https://community.auth0.com/u/johnnyjohnny)\
**Post date:** [March 5, 2019, 4:09am UTC](https://community.auth0.com/t/xamarin-using-refresh-token/22104/1 "2019-03-05T04:09:56Z")

</div>

Hello Auth0 Support Team (and Community!)

I have implemented Auth0 Authentication for a Xamarin Forms App using the example provided here: ([Add Login to Your .NET Android and iOS Application - Auth0 Docs](https://auth0.com/docs/quickstart/native/xamarin/01-login)).

Is there a refresh token example? And/Or, is there a suggested best-practice for Xamarin Forms app to utilize a refresh token when the access token expires OR, when the user closes/returns to the mobile app so that they do not need to login again?

Any help by anyone would be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![zulfiqar](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/zulfiqar/32/3368_2.png) [@zulfiqar](https://community.auth0.com/u/zulfiqar)\
**Post date:** [March 5, 2019, 8:54am UTC](https://community.auth0.com/t/xamarin-using-refresh-token/22104/2 "2019-03-05T08:54:01Z")

</div>

Hey, did you try using “offline\_access” scope in these two lines?

> <https://github.com/auth0-samples/auth0-xamarin-oidc-samples/blob/master/Quickstart/01-Login/Android/AndroidSample/MainActivity.cs#L47>

> <https://github.com/auth0-samples/auth0-xamarin-oidc-samples/blob/master/Quickstart/01-Login/iOS/iOSSample/MyViewController.cs#L39>

---

<div class="post-metadata">

**Author:** ![johnnyjohnny](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/johnnyjohnny/32/12921_2.png) [@johnnyjohnny](https://community.auth0.com/u/johnnyjohnny)\
**Post date:** [March 19, 2019, 10:01pm UTC](https://community.auth0.com/t/xamarin-using-refresh-token/22104/3 "2019-03-19T22:01:20Z")

</div>

Hello @zulfiqar,

Thank you for the reply!

I ended up using:  
\_auth0Client = new Auth0Client(new Auth0ClientOptions  
{  
Domain = AuthenticationConfig.Domain,  
ClientId = AuthenticationConfig.ClientId,  
**Scope = “openid offline\_access”**  
});

This returns a refresh token, which I then re-use when needed by:  
var refreshTokenResult = await \_auth0Client.RefreshTokenAsync(“…”);

It seems to do the trick, I hope this is the proper way to apply this. Open to any suggestions.

Thanks

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [August 30, 2019, 11:42am UTC](https://community.auth0.com/t/xamarin-using-refresh-token/22104/4 "2019-08-30T11:42:28Z")

</div>

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.
