From abfe2c83b2ce96bd665af1a5b245909f4607910c Mon Sep 17 00:00:00 2001 From: James McQuillan Date: Wed, 20 May 2015 10:39:02 -0400 Subject: [PATCH] MSFTMPP-179: Fix token refresh for new resources --- classes/oauth2/token.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/classes/oauth2/token.php b/classes/oauth2/token.php index 3e80d429b..c501c4c73 100644 --- a/classes/oauth2/token.php +++ b/classes/oauth2/token.php @@ -175,7 +175,15 @@ public static function get_for_new_resource($userid, $resource, $clientdata, $ht 'refresh_token' => $aadgraphtoken->get_refreshtoken(), 'resource' => $resource, ]; - $tokenresult = $httpclient->post($clientdata->get_tokenendpoint(), $params); + $params = http_build_query($params, '', '&'); + $tokenendpoint = $clientdata->get_tokenendpoint(); + + $header = [ + 'Content-Type: application/x-www-form-urlencoded', + 'Content-Length: '.strlen($params) + ]; + $httpclient->setHeader($header); + $tokenresult = $httpclient->post($tokenendpoint, $params); $tokenresult = @json_decode($tokenresult, true); if (!empty($tokenresult) && isset($tokenresult['token_type']) && $tokenresult['token_type'] === 'Bearer') {