-
Notifications
You must be signed in to change notification settings - Fork 779
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Retrieving a personal access token after it's been created #552
Comments
+1 |
1 similar comment
+1 |
I created this trait to grab the latest valid token for a user, with the default personal access client. <?php
namespace App\Models\Traits;
use Laravel\Passport\ClientRepository;
use Laravel\Passport\Token;
use Laravel\Passport\TokenRepository;
trait AccessToken
{
/**
* Get personal access token for user.
*
* @return \Laravel\Passport\Token|null
*/
public function getToken(): ?Token
{
return app(TokenRepository::class)->findValidToken(
$this,
app(ClientRepository::class)->personalAccessClient()
);
}
} |
Why not acces it from database? |
Hey there. There's a |
@driesvints it seems those two methods don't include personal access tokens? |
Is it possible for me to retrieve the ACCESS TOKEN string from a Laravel\Passport\Token object? |
I would like to know this too! In passport it is pretty easy to create tokens and clients, but not so easy (not documented well enough) to get tokens after they are created. #edit. I want to get back at my above statement. It seems that some (if not all) services (GitHub too) issue you a personal access token only once. Then you need to store it safely yourself. They usually wil let you delete previously generated tokens, but you cannot view them again. I think that this is just how it is meant to work. |
Do you have code for this task ? |
I am using Laravel 8 and Passport 10.1 . is there any to retrieve a Personal Access Token after it has been created ? |
This thread discussion doesn't reply to who ask to get created Personal Access Token yet ? |
can not reuse a token in server side, the created token is only save by client. And server saved hash( token ), which is not reverseable. HasApiTokens.php
|
My current workflow is:
// Creating a token with scopes... $token = $user->createToken('Pricing Token', ['get-pricing])->accessToken;
Essentially it would be good for the user, once they have logged in to my secured site to download the Token at any time to use on their own site. Essentially I'm using the PAT to identify the user so don't need the full OAUTH workflow.
Reading through the source code, I'm able to regenerate the Access token, but how are we able to retrieve the original Token generated in Step 2.
The text was updated successfully, but these errors were encountered: