Code Monkey home page Code Monkey logo

Comments (6)

sfelix-martins avatar sfelix-martins commented on July 29, 2024

Hi @johnef. In latest versions of Laravel when you run php artisan vendor:publish command all providers available are shown. You should choose SMartins\PassportMultiauth\Providers\MultiauthServiceProvider.

You can run too:

php artisan vendor:publish --provider="SMartins\PassportMultiauth\Providers\MultiauthServiceProvider"

from passport-multiauth.

johnef avatar johnef commented on July 29, 2024

@sfelix-martins thanks for the replay I am using Laravel 5.4,
When I run php artisan vendor:publish --provider="SMartins\PassportMultiauth\Providers\MultiauthServiceProvider" I got the vendor\smartins\passport-multiauth\database\migrations copied to my migration folder which I did migrate and everything was OK with this step but what to do with the providers here?

and then comes to the part Add the provider parameter in your request at /oauth/token I can't understand this part too.

I made all the steps you mention and try to test on postman but from where can I get the client_id and client_secret sorry I am new to this passport and laravel APIs can you please guide me here

from passport-multiauth.

sfelix-martins avatar sfelix-martins commented on July 29, 2024

@johnef

  1. Any packages has migrations, config files, translations, views and you can publish this files to see, edit, etc. In my package the command just publish a migration file. But it's not required to package works.
  2. On laravel passport installation you need to run php artisan passport:install to create the encryption keys needed to generate secure access tokens. You should to use the client_id and client_secret from "password grant" shown by command output.
  3. After install Laravel Passport, on standard use, to create an access token you should send a POST to /oauth/token route passing client_id and client_secret (Generated on php artisan passport:install), grant_type, username and password. To use my package correctly you need add to oauth/token request the parameter provider passing the any provider defined on config/auth.php providers array.
    Example:

In your config/auth.php providers array you add a new provider admins:

return [
    ...

    'providers' => [
        'users' => [
            'driver' => 'eloquent',
            'model' => App\User::class,
        ],

        // ** New provider**
        'admins' => [
            'driver' => 'eloquent',
            'model' => App\Administrator::class,
        ],
    ],
];

In your request parameters should looks like:

// The username and password of any admin created in your API
username: "[email protected]" 
password: "password"
// The grant_type with value `password`
grant_type: "password"
// The client_id and client_secret generated by `php artisan passport:install` command
client_id: "client-id"
client_secret: "client-secret"
// Any provider defined previously
provider: "admins"

The package instructions assumes that the package user already has a previously knowledge in Laravel Passport. I will improve it to make the experience easier.

I hope it helps, Thanks!

from passport-multiauth.

johnef avatar johnef commented on July 29, 2024

@sfelix-martins thanks really for your effort but I try all the steps you just said but when test on postman I get always "error": "Unauthenticated."

from passport-multiauth.

johnef avatar johnef commented on July 29, 2024

@sfelix-martins one more question I see this in the vendor\smartins\passport-multiauth\src\Http\Middleware\AddCustomProvider.php dose it should be published in my Middleware because I see my Middleware is same same even after installing the package.

from passport-multiauth.

sfelix-martins avatar sfelix-martins commented on July 29, 2024

The middleware don’t need to be published to your middlewares. You need just use the middleware. Please, list all steps that you follow to install and configure the package on your project.

from passport-multiauth.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.