Skip to content

Commit 9c70549

Browse files
committed
Add customization of scopes
1 parent be6705c commit 9c70549

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

README.md

+34
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,40 @@ class AuthServiceProvider extends ServiceProvider
237237
}
238238
```
239239

240+
You may also extend the built-in `UserProviderHandler` implementation if you prefer.
241+
242+
For example, if you need to adjust the scopes for a single provider:
243+
244+
```php
245+
namespace App\Socialite;
246+
247+
use Illuminate\Http\RedirectResponse;
248+
use Laravel\Socialite\Contracts\Provider;
249+
use DirectoryTree\Bartender\UserProviderHandler;
250+
251+
class MicrosoftUserHandler extends UserProviderHandler
252+
{
253+
/**
254+
* Handle redirecting the user to Microsoft.
255+
*/
256+
public function redirect(Provider $provider, string $driver): RedirectResponse
257+
{
258+
$provider->scopes([
259+
'Mail.ReadWrite',
260+
// ...
261+
]);
262+
263+
return parent::redirect($provider, $driver);
264+
}
265+
}
266+
```
267+
268+
Then register it as the handler:
269+
270+
```php
271+
Bartender::serve('microsoft', MicrosoftUserHandler::class);
272+
```
273+
240274
### User Creation & Updating
241275

242276
If you would like to customize the creation of the user in the default

0 commit comments

Comments
 (0)