title: How to access Azure Management API China
body: <p>I've written a tool to setup Azure Web Apps, Databases, Storage accounts etc.
  Wt works quite well with general Azure. However, I'd now like to apply the same to <strong>Azure China</strong> now. Now I'm looking for the correct Urls to get a Token form the Active Directory to even access the API endpoint.</p>
  <p>I'm going of these instructions: <a href="https://msdn.microsoft.com/en-us/library/azure/dn722415.aspx" rel="nofollow noreferrer">https://msdn.microsoft.com/en-us/library/azure/dn722415.aspx</a>
  These settings for Azure work perfectly:</p>
  <p><code>oAuthAuthorizationEndpoint=&quot;https://login.microsoftonline.com/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/oauth2/authorize?api-version=1.0&quot;</code>
  <code>apiEndpoint=&quot;https://management.core.windows.net/&quot;</code></p>
  <h3>These are the Azure China urls that I'm using:</h3>
  <p><code>oAuthAuthorizationEndpoint=&quot;https://login.chinacloudapi.cn/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/oauth2/authorize?api-version=1.0&quot;</code>
  <code>apiEndpoint=&quot;https://management.core.chinacloudapi.cn/&quot;</code></p>
  <p>I can now login successfully using TokenCloudCredentials and the above settings.</p>
  <pre><code>this.Credentials = new TokenCloudCredentials(config.SubscriptionId, this.AuthenticationResult.AccessToken);
  this.ResourceManagement = new ResourceManagementClient(this.Credentials, new Uri(config.ApiEndpoint));
  var resourceGroups = this.ResourceManagement.ResourceGroups.ListAsync(new ResourceGroupListParameters(), CancellationToken.None).Result.ResourceGroups;
  Console.WriteLine(&quot;ResourceGroupe: {0}&quot;, string.Join(&quot;, &quot;, resourceGroups.Select(x =&gt; string.Format(&quot;{0}&quot;, x.Name)).ToArray()));
  </code></pre>
  <p>However as soon as I'm trying to access an API as shown above, I'm getting the following exception:
  <strong><code>ForbiddenError: The server failed to authenticate the request. Verify that the certificate is valid and is associated with this subscription.</code></strong></p>
  <p>It's the same exception is thrown by calling <code>this.ResourceManagement.Providers.RegisterAsync(&quot;Microsoft.Storage&quot;)</code></p>
  <p>Has anyone been able to successfully use the Management API for Azure China? How did you do it?</p>
  <p>I'm pretty confident that all my Guids are valid and all the permissions are set correctly. Since I compared it to my working Azure counterpart.</p>
  <p><em>(Guids are obviously masked)</em></p>