Skip to content

Commit 362dcb4

Browse files
committed
Merge branch 'master' of github.com:dcblogdev/laravel-microsoft-graph
2 parents 6aa41dc + 7657ede commit 362dcb4

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/MsGraph.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,9 @@ public function isConnected($id = null)
131131
*/
132132
public function disconnect($redirectPath = '/', $logout = true, $id = null)
133133
{
134-
$id = ($id) ? $id : auth()->id();
135-
$token = MsGraphToken::where('user_id', $id)->first();
134+
$id = ($id) ? $id : auth()->id();
135+
$token = MsGraphToken::where('user_id', $id)->latest()->first();
136+
136137
if ($token != null) {
137138
$token->delete();
138139
}
@@ -155,7 +156,7 @@ public function getAccessToken($id = null, $returnNullNoAccessToken = null)
155156
{
156157
//use id if passed otherwise use logged in user
157158
$id = ($id) ? $id : auth()->id();
158-
$token = MsGraphToken::where('user_id', $id)->first();
159+
$token = MsGraphToken::where('user_id', $id)->where('refresh_token', '<>', '')->latest()->first();
159160

160161
// Check if tokens exist otherwise run the oauth request
161162
if (!isset($token->access_token)) {
@@ -202,9 +203,8 @@ public function getAccessToken($id = null, $returnNullNoAccessToken = null)
202203
*/
203204
public function getTokenData($id = null)
204205
{
205-
$id = $id ?: auth()->id();
206-
207-
return MsGraphToken::where('user_id', $id)->first();
206+
$id = ($id) ? $id : auth()->id();
207+
return MsGraphToken::where('user_id', $id)->where('refresh_token', '<>', '')->latest()->first();
208208
}
209209

210210
/**

src/MsGraphAdmin.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function files()
5353
* Set the base url that all API requests use.
5454
* @var string
5555
*/
56-
protected static $baseUrl = 'https://graph.microsoft.com/beta/';
56+
protected static $baseUrl = 'https://graph.microsoft.com/v1.0/';
5757

5858
/**
5959
* @return object
@@ -85,6 +85,7 @@ public function connect()
8585
'client_id' => config('msgraph.clientId'),
8686
'client_secret' => config('msgraph.clientSecret'),
8787
'grant_type' => 'client_credentials',
88+
'resource' => 'https://graph.microsoft.com',
8889
];
8990

9091
$token = $this->dopost(config('msgraph.tenantUrlAccessToken'), $params);
@@ -131,6 +132,7 @@ public function getAccessToken($returnNullNoAccessToken = null)
131132
'client_id' => config('msgraph.clientId'),
132133
'client_secret' => config('msgraph.clientSecret'),
133134
'grant_type' => 'client_credentials',
135+
'resource' => 'https://graph.microsoft.com',
134136
];
135137

136138
$token = $this->dopost(config('msgraph.tenantUrlAccessToken'), $params);

0 commit comments

Comments
 (0)