Answer the question
In order to leave comments, you need to log in
Laravel Passport, Alexa Skill. How to authorize through implicit flow?
Good afternoon!
1. There is a backend, there are a lot of users on it.
2. There is Alexa's skill
It is not possible to link 1 and 2 so that each user of Alexa (who previously implicitly linked his account with credits) has access to the BE API. Bearer token comes from Alexa with every request, but it's not in the headers, but just in the request body. Of course, Laravel does not pick up authorization, that is, the essence of the problem is that Alexa gives a token, how to find a user using this token and is it possible?
Answer the question
In order to leave comments, you need to log in
Well, in general, I decided flatly and clumsily.
If someone finds a concise solution - share, please.
$request->bearerToken() пишется в middleware при помощи $request->headers->add(['Authorization' => 'Bearer ' . $token]); Но авторизация при этом не появляется.
composer require firebase/php-jwt
...
use \Firebase\JWT\JWT;
...
$publicKey = <<<EOD
-----BEGIN PUBLIC KEY-----
Ключ из storage/oauth-public.key
-----END PUBLIC KEY-----
EOD;
$token = JWT::decode($request->bearerToken(), $publicKey, array('RS256'))->jti;
$item = DB::table('oauth_access_tokens')->where('id', $token)->first();
$user = $item->user_id;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question