Using Google Appengine Python (Webapp2) I need to authenticate to Microsoft's new V2 endpoint using OpenID Connect
<p>There are built in decorators that easily allow me to access Google's own services but how can I overload these decorators to call other endpoints, specifically Microsofts V2 Azure endpoint (I need to authenticate Office 365 users).</p>

<p>Code snippet which I would like to override to call other end points such as Microsofts:</p>

<p><a href="https://login.microsoftonline.com/common/oauth2/v2.0/authorize" rel="nofollow">https://login.microsoftonline.com/common/oauth2/v2.0/authorize</a></p>

<pre><code>decorator = OAuth2Decorator(
  client_id='d4ea6ab9-adf4-4aec-9b99-675cf46ad37',
  redirect_uri='',
  client_secret='sW8rJYvWtCBVpge54L8684w',
  scope='')



class Authtest(BaseRequestHandler):

  @decorator.oauth_required
</code></pre>

<p>Any ideas greatly appreciated.
Thanks,
Ian</p>

<p>Having wasted a lot of time on this I can confirm that you CAN overload the decorator to direct to the Azure V2 endpoint using the code below:</p>

<pre><code>decorator = OAuth2Decorator(
  client_id='d4ea6ab9-adf4-4aec-9b99-675cf46XXX',
  auth_uri='https://login.microsoftonline.com/common/oauth2/v2.0/authorize',

  response_type='id_token',
  response_mode='form_post',
  client_secret='sW8rJYvWtCBVpgXXXXX',
  extraQueryParameter='nux=1',
  state='12345',
  nonce='678910',
  scope=['openid','email','profile'])
</code></pre>

<p>Problem is that the decorators are coded purely to handle Google APIs and can not decode the response from Microsoft, whilst it may be possible to implement this myself by modifying the code in appengine.py it's too much work.</p>

<p>So if you are looking to authenticate to the Microsoft Azure V2 endpoint via Appengine it is not possible by using the built in OAuth2Decorator this only works with Google's own services.</p>

python google-app-engine azure office365 webapp2