title: OneLogin OIDC grant request is invalid
body: <p>I have a Java application with an Angular 4 front end and I'm trying to implement Open ID Connect authorization with OneLogin.  I have the app configured in OneLogin with a redirect URL that is an API endpoint to collect the code generated by OneLogin.  Steps 1 - 3 are working as described in the OneLogin documentation, but step 4 fails every time and I cannot figure out why.</p>
  
  <p><em>Step 1</em>: the user attempts to start a session with your client app and is redirected to the OpenID Provider (OneLogin), passing in the client ID, which is unique for that application. - <strong>This works, the user is redirected to a login page hosted by OneLogin.</strong></p>
  
  <p><em>Step 2</em>: the OpenID Provider authenticates and authorizes the user for a particular application instance. - <strong>This works</strong></p>
  
  <p><em>Step 3</em>: a one-time-use code is passed back to the web server using a predefined Redirect URI. - <strong>The URI is an API endpoint on the server and it does successfully get the code from OneLogin</strong></p>
  
  <p><em>Step 4</em>: the web server passes the code, client ID, and client secret to the OpenID Provider’s token endpoint, and the OpenID Provider validates the code and returns a one-hour access token. - <strong>This is where it falls apart for me.</strong></p>
  
  <p>The only response I get back is "grant request is invalid".  The HTTP POST that I am constructing for this step looks like this:</p>
  
  <pre><code>curl -XPOST "https://openid-connect.onelogin.com/oidc/token"
  -H "Content-Type: application/x-www-form-urlencoded"
  -d "grant_type=authorization_code
  &amp;code=&lt;code returned in step 3&gt;
  &amp;redirect_uri=https%3A%2F%2Flocalhost
  &amp;client_id=&lt;My OIDC Client ID&gt;
  &amp;client_secret=&lt;My OIDC Client Secret&gt;"
  </code></pre>
  
  <p>And the response every time is:</p>
  
  <pre><code>{
      "error": "invalid_grant",
      "error_description": "grant request is invalid"
  }
  </code></pre>
  
  <p>I'm at a complete loss as to what to try next.</p>