forked from exment-oauth/microsoft-graph
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMicrosoftGraphProvider.php
40 lines (34 loc) · 1.01 KB
/
MicrosoftGraphProvider.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
namespace ExmentOauth\MicrosoftGraph;
use Exceedone\Exment\Auth\ProviderAvatar;
use SocialiteProviders\Graph\Provider;
class MicrosoftGraphProvider extends Provider implements ProviderAvatar
{
/**
* Get avatar stream
* @param mixed $token
* @return string
*/
public function getAvatar($token = null){
try
{
$client = $this->getHttpClient();
$response = $client->get('https://graph.microsoft.com/v1.0/me/photo/$value', [
'headers' => [
'Authorization' => 'Bearer '.$token,
'Content-Type' => 'application/json;odata.metadata=minimal;odata.streaming=true'
],
'http_errors' => false,
]);
if($response->getStatusCode() == 404){
return null;
}
return $response->getBody()->getContents();
}
catch (\Exception $exception)
{
return null;
}
return null;
}
}