title: Azure Active Directory, Django Rest Social Auth
body: <p>I prepare OAuth login via Microsoft Azure with django-rest-social-auth lib. I configure azure like this:</p>
  <p><a href="https://i.stack.imgur.com/hSkwv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hSkwv.png" alt="enter image description here" /></a></p>
  <p><a href="https://i.stack.imgur.com/GOfNS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GOfNS.png" alt="enter image description here" /></a></p>
  <p>Of course I add certificate secret key and register app with client id. I use <a href="https://github.com/st4lk/django-rest-social-auth" rel="nofollow noreferrer">Django REST</a> lib which rests on <a href="https://github.com/python-social-auth/social-core" rel="nofollow noreferrer">social_core</a>. I debug this app but I dont know what I do wrong. And I request for code to:</p>
  <blockquote>
  <p><a href="https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=id-client&amp;response_type=code&amp;redirect_uri=http://localhost:8000/&amp;scope=openid+email+profile+User.Read&amp;state=ewrqwer23r32rew&amp;response_mode=query" rel="nofollow noreferrer">https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=id-client&amp;response_type=code&amp;redirect_uri=http://localhost:8000/&amp;scope=openid+email+profile+User.Read&amp;state=ewrqwer23r32rew&amp;response_mode=query</a></p>
  </blockquote>
  <p>when I got the code I post to:</p>
  <blockquote>
  <p><a href="https://login.microsoftonline.com/common/oauth2/token" rel="nofollow noreferrer">https://login.microsoftonline.com/common/oauth2/token</a></p>
  </blockquote>
  <p>and when my lib doesnt work, below my request via django-rest-social-app:</p>
  <blockquote>
  <p>{'method': 'POST', 'url': 'https://login.microsoftonline.com/common/oauth2/token', 'headers': {'User-Agent': 'python-requests/2.23.0', 'Accept-Encoding': 'gzip, deflate', 'Accept': 'application/json', 'Connection': 'keep-alive', 'Content-Type': 'application/x-www-form-urlencoded', 'Content-Length': '214'}, '_cookies': &lt;RequestsCookieJar[]&gt;, 'body': 'grant_type=authorization_code&amp;code=Md6d97b25-d830-9a29-20b3-6c97a482a3de&amp;client_id=client-id&amp;client_secret=ssecret&amp;redirect_uri=http%3A%2F%2F127.0.0.1%3A8000%2F', 'hooks': {'response': []}, '_body_position': None}</p>
  </blockquote>
  <p>I got message:</p>
  <blockquote>
  <p>&quot;error&quot;:&quot;invalid_grant&quot;,&quot;error_description&quot;:&quot;AADSTS9002313: Invalid request. Request is malformed or invalid.</p>
  </blockquote>
  <p>I think ok, I dont have scope in this request, than I got postman and I post request with body:</p>
  <p><a href="https://i.stack.imgur.com/Ed73V.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ed73V.png" alt="enter image description here" /></a></p>
  <p>and I got the same anwer.</p>
  <p>What do I do wrong? Maybe someone use this lib or integrate with social_core with microsoft azure.</p>