Using package in laravel
Please help me, i'm confused I have project using laravel and laravel socialite, i got access_token from laravel socialite. How to use that access_token in this package?
I use this method
$tokenRequestContext = new OnBehalfOfContext(
config("services.microsoft.tenant"),
config("services.microsoft.client_id"),
config("services.microsoft.client_secret"),
session()->get("microsoft_access_token"),
);
$graphServiceClient = new GraphServiceClient($tokenRequestContext);
$user = $graphServiceClient->me()->get()->wait();
dd($user);
why the process is very long, and the result is invalid grant? I have checked that all parameters (tenant id, client id, etc) are valid
why this package doesn't implement it easily like microsoft graph postman collection, i can even input manual access token in postman header and call api directly
with symfony i use this code if it can help you
$tokenRequestContext = new ClientCredentialContext(
$this->tenantId,
$this->clientId,
$this->clientSecret,
);
$accessToken = new AccessToken([
'access_token' => $oauthUser->getAccessToken(),
'refresh_token' => $oauthUser->getRefreshToken(),
]);
$scopes = ['User.Read', 'Mail.ReadWrite', 'Mail.Send'];
$inMemoryCache = new InMemoryAccessTokenCache($tokenRequestContext, $accessToken);
$graphServiceClient = GraphServiceClient::createWithAuthenticationProvider(
GraphPhpLeagueAuthenticationProvider::createWithAccessTokenProvider(
GraphPhpLeagueAccessTokenProvider::createWithCache(
$inMemoryCache,
$tokenRequestContext,
$scopes
)
)
);
thanks for the suggestion, i will try it later. i followed this solution and it worked 1472