title: how to setup Azure AD Client Credentials Flow with Mediawiki
body: <p>I am trying to setup a Mediawiki on Azure. And need to have OAuth support with Client Credentials Flow so a client application can request access token from Azure AD, and then client uses the requested access token to call Mediawiki API to access wiki resources.</p>
  <p>I am wondering what are the steps I can follow in order to have such setup.</p>
  <p>Currently I am thinking use Azure Web App to create Mediawiki and turn on Express Auth mode in AAD for this app. Not sure if I still need to configure anything in Mediawiki for validating the access token or any extension needed.</p>
  <p>I also saw some tutorials create VM instead of Azure Web App. But I can not find any Client Credentials tutorials for Mediawiki.</p>
  <p>[<strong>Update section below</strong>]</p>
  <p>I would like to clearify my question a bit more in case I didn't.
  I would like to configure Azure AD (which is an Identity platform) to enable client credential. So my client app can get access token from Azure AD and then client app can use this token to query data directly to Medaiwki API.</p>
  <p>Example:</p>
  <p>Step 1:
  Client send post request to Azure AD endpoint using client crendentials</p>
  <pre><code>POST:
  https://login.microsoftonline.com/xxxxxx_an_AAD_tenantID_xxxxxxxxxxxx/oauth2/token
   
  Headers:
  Content-Type: multipart/form-data;
   
  Body:
  {
      client_id=&lt;New App Registration Client ID&gt;,
      client_secret=&lt;New App Registration Client Secret&gt;,
      grant_type=client_credentials
  }
   
  Response:
  {    
      &quot;token_type&quot;: &quot;Bearer&quot;,    
      &quot;expires_in&quot;: &quot;xxx&quot;,    
      &quot;ext_expires_in&quot;: &quot;xxx&quot;,    
      &quot;expires_on&quot;: &quot;xxx&quot;,    
      &quot;not_before&quot;: &quot;xxxx,    
      &quot;resource&quot;: &quot;xxx&quot;,    
      &quot;access_token&quot;: &lt;Access_Token&gt;
  }
  </code></pre>
  <p>Step 2: using the Access token from step 1 to query Medaiwiki API data</p>
  <pre><code>GET:
  https://myMediawiki.com/api.php?action=query&amp;meta=siteinfo&amp;siprop=namespaces&amp;format=json
   
  Headers:
  Authorization: Bearer &lt;Access_Token&gt;
  </code></pre>
  <p>I am wondering <strong>how to configure such Mediawiki</strong>. In order to take the access token at Mediawiki.</p>
  <p>I understand there are some OAuth extensions. But those extensions seem to act as a whole authorization server. In my case, I would like AAD act as Authorization Server and AAD will create authorized Client App with client_id and Client_secret in step 1.</p>
  <p>Some references:</p>
  <ul>
  <li><a href="https://docs.microsoft.com/en-us/azure/active-directory/azuread-dev/v1-oauth2-client-creds-grant-flow" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/azure/active-directory/azuread-dev/v1-oauth2-client-creds-grant-flow</a></li>
  <li><a href="https://dasith.me/2018/12/31/client-credentials-flow-with-azuread/" rel="nofollow noreferrer">https://dasith.me/2018/12/31/client-credentials-flow-with-azuread/</a></li>
  </ul>