Josh Ripley
Josh Ripley

Reputation: 239

Azure AD OAuth Access Token Request ::: 400 - Bad Request

I have a php web app built upon Laravel 5 / Socialite, where I am trying to implement a SSO solution with windows azure AD OAuth flow, but I am getting a generic "400 Bad Request Error" on the second OAuth request for an Access Token.
The first request to the office 365 authorize URL is successful and returns an authorization code to my app, but when I try to get a user access token it fails.

I have checked and rechecked my request and it appears correct as much as I can tell:

POST https://login.windows.net/common/oauth2/token

HEADERS

Host:login.windows.net
Content-type:application/x-www-form-urlencoded
User-Agent: wTrack/.001
Date: Thu, 21 May 2015 02:48:43 GMT 

BODY

client_id=1ad9f025-dfaf-4cb7-a9ff-29ea619bab44&
client_secret=<secret>&
code=<code>&
redirect_uri=https%3A%2F%2Fwtrack.dev%2Flogin%2Fmicrosoft&
grant_type=authorization_code

I have been looking at this for quite some time. Any help that could be provided would be greatly appreciated.

Upvotes: 1

Views: 5999

Answers (1)

Jason Johnston
Jason Johnston

Reputation: 17702

Make sure your redirect_uri is the same as the one you used for the authorization code request. Also, you might try adding the resource parameter in your request body.

Upvotes: 2

Related Questions