Domanda

I save tokens obtained through authorization and use them for post and similar requests. However I need to know when to re-login in case of token expiration.

Does scribe throw any relative exception ? Judging by the sources it doesn't but maybe it throws any other ? Maybe you can suggest a better way ?

È stato utile?

Soluzione

Scribe can't tell if a token is expired or not. There's no standard way in OAuth for the provider to inform you that a token was valid and now it isn't.

It's kind of logical that it works that way, tokens have a life span and after that they become rubbish. There's no way of differentiating between a just-expired token and a random string.

The only way you can check is (surprise!) making a request and seeing if it works. Your client can keep some kind of state to check wether the request is getting an unauthorized response with a previously valid token and in that case try to reauthenticate but, sadly, there's no way the provider (or scribe for that matter) can make that easier for you. Sorry.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top