iOS Refresh Token Expired - How to refresh token?

Hey guys

    let credentials = Credentials.anonymous credentials) { result in

I’m logging in to Realm as Anonymous. But after a time realm response is: Refresh Token Expired

I’ve tried to log out, but I get the same error when trying to log back using the same code I also get like: Refresh Token Expired

Any idea how I can refresh token?

Hi Fabricio - welcome to the community!

Anonymous Authentication isn’t intended to persist data. If the user logs out, or the refresh token expires, the user can’t retrieve any previous user data. If you need to persist user data, you’ll want to register an account with a more permanent authentication method and then link the user identities. There’s an example of this on the Link User Identities page.

1 Like

Thanks Dachary,

In our app we dont store user data, that’s why we are login anonymously.

If we link every anonymous user to a same user identifier, it would cause any issue?

I say it because we really dont need user data on this app


Ahh, I see. I’m not sure what exactly would happen if you tried to link every anonymous user to one user identifier, but I don’t think it’s possible. A better option might be to use a custom function to log in users, and then you can pass some arbitrary param - maybe a UUID for the user? - but not necessarily require a user-facing login.

Hi Dachary,
Issue Fabricio is trying to solve is that one user is stuck with a bad token and he is not able to find a way to either clear that token and login again from that given device or refresh a token. iOS SDK for swift seems to be missing documentation about how and what method to call to refresh a token.

Maybe the user is stuck in an error condition - are you able to share trace level Sync logs from the client?

If you want to just unblock the user, you should be able to start from 0 by wiping the local state by uninstalling and reinstalling the app.

the custom function seems to have solved the problem for now

Thank you

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