title: Getting the "The provided value for the 'redirect_uri' is not valid" error when I try to get the access token
body: <p>When I try to get the token I get the error:</p>
  
  <p><code>The provided value for the 'redirect_uri' is not valid. The value must exactly match the redirect URI used to obtain the authorization code.</code></p>
  
  <p>My redirect uri exactly matches so I don't understand why it is happening.</p>
  
  <pre><code>$TOKEN_ENDPOINT         = 'https://login.microsoftonline.com/common/oauth2/v2.0/token';
  $params = array(
      'grant_type'              =&gt; 'authorization_code',
      'code'                    =&gt; $azureCode,
      'clientId'                =&gt; '7c09ab71-***-****-****-53d7c4438112',
      'clientSecret'            =&gt; 'bnot*******20*[',
      'redirect_uri'            =&gt; 'https://testing.****.com/outlookOauthCallback.php',
      'urlAuthorize'            =&gt; $AUTHORIZATION_ENDPOINT,
      'urlAccessToken'          =&gt; $TOKEN_ENDPOINT,
      'urlResourceOwnerDetails' =&gt; '',
      'scope'                   =&gt; 'Calendars.ReadWrite User.Read'
  );
  $response = $client-&gt;getAccessToken($TOKEN_ENDPOINT, 'authorization_code', $params);
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/NpuEB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NpuEB.png" alt="enter image description here"></a></p>
  
  <p>(Trust me the part I turned into stars is exactly the same because I copy pasted)</p>
  
  <p>Even in the response where I returned the params it is exactly the same:</p>
  
  <pre><code>Array
  (
      [grant_type] =&gt; authorization_code
      [code] =&gt; M51b1b*****-daeec54627b2
      [clientId] =&gt; 7c09ab71-a*****d7c4438112
      [clientSecret] =&gt; bnotxds&amp;*&amp;QB***cVLF20*[
      [redirect_uri] =&gt; https://testing.****.com/outlookOauthCallback.php
      [urlAuthorize] =&gt; https://login.microsoftonline.com/common/oauth2/v2.0/authorize
      [urlAccessToken] =&gt; https://login.microsoftonline.com/common/oauth2/v2.0/token
      [urlResourceOwnerDetails] =&gt; 
      [scope] =&gt; Calendars.ReadWrite User.Read
  )
  </code></pre>
  
  <p>So how can it still be giving me this error? What am I missing here?</p>