passport-custom-request-grant | Custom Request Grant for Laravel Passport | REST library
kandi X-RAY | passport-custom-request-grant Summary
kandi X-RAY | passport-custom-request-grant Summary
Custom Request Grant for Laravel Passport
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Respond to an access token
- Get user entity by request .
- Validate the user .
- Make a custom request grant .
- Boot the application .
- Get unique identifier .
- Register plugin .
passport-custom-request-grant Key Features
passport-custom-request-grant Examples and Code Snippets
Community Discussions
Trending Discussions on passport-custom-request-grant
QUESTION
I have been tinkering with the laravel passport and i can not seem to implement a custom grant type. I am using laravel 5.6 with passport 6.0 . After research, i created a CustomRequestGrantProvider and a CustomRequestGrant likewise in this CustomGrant library but i had no luck and every time i would make a POST request to localhost:8000/oauth/token with grant_type, client_id and client_secret
...ANSWER
Answered 2019-Dec-24 at 14:16So i ended up creating custom classes that implement the original classes (Take a look at the picture below).
The classes needed from the laravel/passport trait are the classes in the picture below with out the Custom in the beginning.
For the CustomUserRepositoryInterface, you only need to modify UserRepositoryInterface, if for example you need to send an extra parameter to the laravel post request.
This gave me the ability to customize laravel passport heavily, like for example passing multiple account types that have different ways of accessing the app(like sign in with phone number, email, facebook_token and id).
I am sorry that i did not go thoroughly into the answer, but i was thinking of creating a library and sharing my work on github and off course update the answer and share the link, but non the less, these are the only classes you need to alter to achieve such result.
Have a splendid day :)
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install passport-custom-request-grant
Add MikeMcLin\Passport\CustomRequestGrantProvider to your list of providers after Laravel\Passport\PassportServiceProvider.
Add byPassportCustomRequest($request) method to your User model (or whatever model you have configured to work with Passport). The method should accept an Illuminate\Http\Request object. You should authorize and retrieve user based on this request If you find that the request met your requirement, return the User model. If the request did not satisfy your requirement, return null
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page