PHP code example of artisanpack-ui / microsoft-oauth
1. Go to this page and download the library: Download artisanpack-ui/microsoft-oauth library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use ArtisanPackUI\Hooks\Facades\Filter;
// In your service provider's boot() method:
Filter::add( 'ap.microsoft.oauth.scopes', function ( array $scopes ): array {
$scopes[] = 'https://www.bingapis.com/api/v7/businesses.readwrite';
return $scopes;
} );
use ArtisanPackUI\MicrosoftOAuth\Contracts\TokenProvider;
public function __construct( protected TokenProvider $tokens ) {}
public function fetchProfile( int $userId ): array
{
return Http::withToken( $this->tokens->accessTokenFor( $userId ) )
->acceptJson()
->get( 'https://graph.microsoft.com/v1.0/me' )
->json();
}