Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RenewAsync fails with NRE after initial success #99

Open
bryanapellanes-okta opened this issue Sep 23, 2022 · 5 comments
Open

RenewAsync fails with NRE after initial success #99

bryanapellanes-okta opened this issue Sep 23, 2022 · 5 comments
Assignees

Comments

@bryanapellanes-okta
Copy link
Contributor

    I am using okta.Xamarin(3.1.0). 
configured the file in asset folder inside android project with following content :

<?xml version="1.0" encoding="UTF-8" ?>
<Okta>
    <ClientId>client Id</ClientId>
    <OktaDomain>domainn url</OktaDomain>
    <RedirectUri>redirect url</RedirectUri>
    <PostLogoutRedirectUri>logout url</PostLogoutRedirectUri>
    <Scope>openid profile offline_access</Scope>
</Okta>

used await OktaContext.Current.SignInAsync(); this method to get access token , id token and refresh token.
saved all information in preferences.

then added a custom login to check if the access token is expired or not like following


Preferences.Get(PreferencesKey.ExpiryTime, DateTime.UtcNow)< DateTime.UtcNow.AddMinutes(5);

and then if the access token has expired then called renew token by passing stored refresh token 
await OktaContext.Current.RenewAsync(refreshToken);

this time I am getting response with refresh token and the expiresIn seconds , so I Updated both values in preferences like:

expiresIn = DateTime.UtcNow.AddSeconds(renewedToken.ExpiresIn);
RefreshToken = renewedToken.RefreshToken;



Now , after the expiration of this new refresh token that means (3600) when aI tries to get new refresh token with 
await OktaContext.Current.RenewAsync(refreshToken); I am getting a response with null values and the exception of object reference not set

Originally posted by @NiranjanXamarin in #59 (comment)

@bryanapellanes-okta
Copy link
Contributor Author

Internal Ref: OKTA-535318

@NiranjanXamarin
Copy link

Want to add one observation here,
In the response of refresh token of first time , we get new access token but the the refreshtoken inside response is same. that means when we tries to get new refresh token second time(after 3600 the expiration time) we provide the same refresh token what we used in first time. so eventually we will use same refresh token for all future calls for renew token. if this is an expected behaviour then you can ignore this observation.

My assumption is from renew token method, along with new access token we should receive new refresh token as well. correct me if I am wrong.

@NiranjanXamarin
Copy link

hello @bryanapellanes-okta any update on this ?

@bryanapellanes-okta
Copy link
Contributor Author

@NiranjanXamarin No update yet; this item has been slotted to an upcoming sprint with other priorities taking precedence. I will comment here when there is more to share.

@GnanaPriyaNamasivayam
Copy link

When I was facing NRE while logging into the app, I added a few additional properties in my oktaconfig file like serverId, discovery endpoints, authstatekey, authservicediscovery key like those. It worked for me.
Hope it helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants