Unlike Github Bitbucket provides you only one hour valid tokens so you will need to refresh access tokens. $refreshToken = $user->refreshToken // may not always be provided Once you have a user instance, you can grab a few more details about the user: $user = Socialite::driver('bitbucket2')->user() The redirect method takes care of sending the user to the OAuth provider, while the user method will read the incoming request and retrieve the user's information from the provider.īitbucket Oauth2 does not support scopes on request, all scopes are configured in Oauth application settings. Route::get('auth/bitbucket/callback', 'Auth\ ') Of course, you will need to define routes to your controller methods: Route::get('auth/bitbucket', 'Auth\ ') $user = Socialite::driver('bitbucket2')->user() * Obtain the user information from GitHub. We will access Socialite using the Socialite facade: redirect() So now, you are ready to authenticate users! You will need two routes: one for redirecting the user to the OAuth provider, and another for receiving the callback from the provider after authentication. 'client_secret' => env('BITBUCKET_CLIENT_SECRET'), 'client_id' => env('BITBUCKET_CLIENT_ID'), You may copy the example configuration below to get started: 'bitbucket' => [ They should be placed in your config/services.php file. You will also need to add credentials for the OAuth application that you can get on the Oauth settings page of you Bitbucket account. Then you should register service provider in your config/app.php file: 'providers' => [Īlexsoft\LaravelSocialiteBitbucket\Provider::class, Note: if you use Laravel 5.5+ you can skip service provider registration, because it should be auto discovered. composer require alexsoft/laravel-socialite-bitbucket:^1.0 Laravel 5.4+ composer require alexsoft/laravel-socialite-bitbucket You can install the package via composer: This package allows you to use Laravel Socialite using OAuth 2 of Bitbucket. Bitbucket OAuth2 Provider for Laravel Socialite Laravel Socialite itself supports Bitbucket oAuth 2.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |