How to generate refresh_token?

Created on 8 June 2023, about 2 years ago
Updated 9 June 2023, about 2 years ago

At my wits end trying to figure this out.

I successfully have /oauth/token generating a JSON response with a token_type, expires_in, and access_token. Documentation suggests that this request can also make a refresh_token, but I can't figure out how to configure it.

I can see where I would use a refresh token if I had one, but how do I get one in the first place?

💬 Support request
Status

Fixed

Version

6.0

Component

User interface

Created by

🇨🇦Canada TrevorBradley

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @TrevorBradley
  • Status changed to Fixed about 2 years ago
  • 🇳🇱Netherlands bojan_dev

    Refresh tokens are optional, you can enabled it on the consumer entity under the grant types /admin/config/services/consumer. Scopes can now be specific for grant types, so you will need to enable the "Refresh token" grant type as well on the associated scopes /admin/config/people/simple_oauth/oauth2_scope/dynamic.

    If you have more questions, feel free to reach out.

  • 🇨🇦Canada TrevorBradley

    I see where Refresh Token can be enabled on both the Consumer entity and the Scope. However, I thought this was about *accepting* the refresh token, rather than *generating* one as part of the Client Credentials authorization. I'm still only getting access_tokens from /oauth/token, no matter how I seem to configure the consumer or scope.

    Do I need to parameterize the request to /oauth/token in some way to get it to generate a refresh_token alongside my access_token? Right now I'm just passing in client_id, grant_type (set to client_credentials for now), and scope (although that's optional, it will use the default if I don't)

    Obviously using grant_type = refresh_token is incorrect here - I need the refresh token before I can use it.

  • Status changed to Active about 2 years ago
  • 🇨🇦Canada TrevorBradley

    I'm pretty sure a client_credentials request doesn't generate refresh tokens. vendor/league/oauth2-server/src/Grant/ClientCredentialsGrant.php::respondToAccessTokenRequest() only generates Access Tokens. By comparison, AuthCodeGrant seems to generate both AccessToken and Refresh Tokens.

    Let me ditch Client Credentials and try to get Authorization Codes working.

  • 🇨🇦Canada TrevorBradley

    Verified - Once I figured out the dance of the authorization code flow - a grant_type:authorization_code correctly returns a refresh_token, but a simple client_credentials does not. Presumably because "Client Credentials" are about the credentials of an app, rather than being the credentials of a user. Simple clients don't need refresh tokens.

  • Status changed to Fixed about 2 years ago
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024