In the process of implementing a OAuth app for Stack Exchange, I noticed that none of the approaches that conventionally work - supplying a offline_access
scope, for example - result in the OAuth exchange exchanging a code for both an access_token
and a refresh_token
.
Additionally, the documentation makes no mention of a refresh_token
(in fact, /docs/authentication doesn't even contain the word 'refresh').
Is the expectation that the developer would always use no_expiry
if they don't want to prompt the user to re-authenticate every day? Or is there a different request that I should be making?
URLs tried:
- Valid request
/oauth?response_type=code
&scope=read_inbox+private_info
&state=ey...AA
&client_id=1111
&redirect_uri=https://valid_redirect_url
- Works fine, but gives me a token that's only valid for a day.
- Add a
refresh_token
to the scope.
/oauth?response_type=code
&scope=read_inbox+private_info+refresh_token
&state=ey...AA
&client_id=1111
&redirect_uri=https://valid_redirect_url
- Scope error.
- Add a
offline_access
to the scope.
/oauth?response_type=code
&scope=read_inbox+private_info+offline_access
&state=ey...AA
&client_id=1111
&redirect_uri=https://valid_redirect_url
- Scope error.
- Add a
grant_type=refresh_token
to the scope.
/oauth?response_type=code
&scope=read_inbox+private_info
&state=ey...AA
&client_id=1111
&redirect_uri=https://valid_redirect_url
&grant_type=refresh_token
- No change in response.
What is the correct process to acquire a refresh token, or should I always specify the no_expiry
scope?