I am using Microsoft.WindowsAzure.MobileServices.MobileServiceClient to authenticate users with their Google accounts and Xamarin.Auth.AccountStore to store tokens. When app runs for first time, AccountStore is empty. User loggs in using MobileServiceClient.LoginAsync method.
client.LoginAsync(_mainActivity,
MobileServiceAuthenticationProvider.Google, "myjobdiary", new Dictionary<string, string>
{
{ "access_type", "offline" }
});
Everything works fine, user is authorized and token stored using method..
public void StoreTokenInSecureStore(MobileServiceUser user)
{
var account = new Account(user.UserId);
account.Properties.Add("token", user.MobileServiceAuthenticationToken);
_accountStore.Save(account, "myjobdiary");
}
Now i restart my app and rerieve user from account store using method..
public MobileServiceUser RetrieveTokenFromSecureStore()
{
var accounts = _accountStore.FindAccountsForService("myjobdiary");
if (accounts != null)
{
foreach (var acct in accounts)
{
if (acct.Properties.TryGetValue("token", out string token))
{
return new MobileServiceUser(acct.Username)
{
MobileServiceAuthenticationToken = token
};
}
}
}
return null;
}
Retrieved user is set to used MobileServiceClient. Now I want to refresh token using MobileServiceClient.RefreshUserAsync method. Exception 'Refresh failed with a 403 Forbidden error. The refresh token was revoked or expired.' occured. mobile apps with azure, refresh tokens