![]() ![]() In this step, you will install socialite library in laravel using the provided command: composer require laravel/socialite * Obtain the user information from GitHub.Subsequently, install needed dependencies: npm installĮxecute command to compile scripts: npm run devĮventually run migration with recommended command: php artisan migrate Install and Setting Up Socialite Pacakage Return Socialite::driver('github')->redirect() * Redirect the user to the GitHub authentication page. RoutesĪdd these routes to routes.php (you can make them anything you want, but this is the convention): Route::get('auth/github', let's fill out those controller methods: Controller methods Let's set up our routes and controller methods. env files: GITHUB_ID=client id from githubīoom. This lives in config/services.php, and as you can see, I've chosen to reference environment variables instead of pasting the values directly in: 'github' => [ Now, let's paste the authentication information in where Socialite can access it. Note: You can create a separate Application later for the production version of the site that has the production callback URL, or you can just adjust this once you go live-but that'll mean this authentication feature won't work locally anymore. , but you should set it to whatever the GitHub callback URL will be on your development environment. ![]() So, visit GitHub's New Application page, fill out the form, and grab your client ID and secret.įor now, I'm setting the callback URL to be: Once you complete it, you'll usually get a client ID and a client Secret, which we need to capture in order to configure Socialite correctly. The application will ask you questions like "What's the name of your application", "What's the callback URL", etc. If you're new to OAuth, you'll need to create an account and then an Application with each service provider. If you wanted, though, you could use one of the other options, or you could set up multiple authentication options.įirst, let's go to GitHub and set up a new Application. Create GitHub appįor this particular example, we'll be using GitHub as our authentication provider. Socialite is now hooked into your application and booting. To hook Socialite into your Laravel application, edit config/app.php and add the following line to the Service Providers array: Laravel\Socialite\SocialiteServiceProvider::class,Īnd add the following line to the Aliases array: 'Socialite' => Laravel\Socialite\Facades\Socialite::class, Install Socialite $ composer require laravel/socialite OK, so now you understand the basic flow, let's get started with Socialite.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |