Hi
I've got a vanilla installation of Laravel 8 on my laptop and have added the microsoft/microsoft-graph installed (https://packagist.org/packages/microsoft/microsoft-graph).
When I now click a button called Onedrive, i do the following:-
$guzzle = new \GuzzleHttp\Client();
$url = 'https://login.microsoftonline.com/' . $tenantId . '/oauth2/token?api-version=1.0';
$token = json_decode($guzzle->post($url, [
'form_params' => [
'client_id' => $clientId,
'client_secret' => $clientSecret,
'resource' => 'https://graph.microsoft.com/',
'grant_type' => 'client_credentials',
],
])->getBody()->getContents());
$accessToken = $token->access_token;
I've added my tentantId, clientId, clientSecret but then when I do:-
$graph = new Graph();
$graph->setAccessToken($accessToken);
$user = $graph->createRequest("GET", "/me")
->setReturnType(Model\User::class)
->execute();
I get a 403 forbidden so I can take it that the access token doesn't work!
And to prove that, if I use Microsoft Graph API Explorer and then login as me, run it and copy/paste the access token used in explorer and put that in my code above, I get what I need!
My questions are:-
To use the Microsoft Graph API, do I need to log every time I run my laravel system (as the examples if you create it from the microsoft pages).
Any idea of what I've not set correctly within the API creation within azure (to be honest, the whole thing is complicated as hell to me!)
I have a website that has many organisations that log in and enter data, we have google drive and dropbox configured so that it works seemlessly and want the same to add onedrive integration. This is so we can create and save documents and pdf's into the clients own dropbox/google drive area.
What I want to be able to do, is store tenantId/clientId/clientSecret (and anything else if I am missing anything) to give seamless access and not have to do a microsoft login.
Hope I've managed to explain my issue without too much confusion!
Seasons greetings
Carl.