Problem/Motivation

I need to programmatically generate access_token & refresh_token for a user. I will know the users id & client_id against which the user has to be authenticated. As done from backend, we wont have and need the users password.

I tried using the class use
League\OAuth2\Server\Grant\AbstractGrant;

And then tried to access the logic for token as below:

   $access_token = $this->issueAccessToken(
      $accessTokenTTL,
      $client,
      $this->getDefaultUser($client),
      $finalized_scopes
    );

After several hours of attempts, I am still stuck. Is there a easy way to do this? In my site, users authenticate via SMS and wont't have a password.

Comments

esafwan created an issue. See original summary.

esafwan’s picture

Is this something that is technically doable?

e0ipso’s picture

Hello!

Did you try creating a new grant plugin, like the other grants shipped by the module?

e0ipso’s picture

Status: Active » Needs work

I would be interested in adding more grants to the module if it's general and you care to share.

Setting to Needs Work awaiting for feedback.

bradjones1’s picture

Title: Generate token for a user_id programmatically » PHP API for creating access and refresh tokens outside of HTTP flow
Category: Support request » Feature request
bradjones1’s picture

Status: Needs work » Closed (duplicate)
Related issues: +#3135825: how to generate new token programatically

Closing as duplicate of other support request - I think the OP's issue is with implementing the abstract grant class?