Configure Github as the OAuth 2.0 provider

suvra jyoti 156 Reputation points
2022-01-05T09:55:39.15+00:00

Hi,

The link https://learn.microsoft.com/en-us/azure/api-management/api-management-howto-oauth2 provides the steps to configure your API Management service instance to use OAuth 2.0 authorization for developer accounts. But it does not show how to configure an OAuth 2.0 provider.

The steps provided above use Azure Active Directory.

How do i go about configuring the Github as the OAuth2.0 provider and the same service to be used by the API management instance and that gets used by the corresponding developer portal. The developer portal can use the same Authentication in test console. I would need the values below:

Client registration page URL:
Authorization endpoint URL :
Token endpoint URL
Client ID & Client secret(obtained during the creation and configuration process of your OAuth 2.0 server)

In the below snapshot we can see the kind of functionality we want :
162521-oauth-in-developer-portal-test-console.jpg

Here is the link from where the snapshot has been provided : https://www.youtube.com/watch?v=yXFP-2r9T94&t=2068s

Let me know if additional details are needed

Thanks

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
2,453 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Pramod Valavala 20,656 Reputation points Microsoft Employee Moderator
    2022-01-13T06:14:48.953+00:00

    @suvra jyoti I was able to get this work with a GitHub OAuth App with the following values (the other required values can be anything and don't affect the functionality per se)

       Authorization Endpoint URL: https://github.com/login/oauth/authorize  
       Token Endpoint URL: https://github.com/login/oauth/access_token  
       Client ID: **Get this from your OAuth App**  
       Client Secret: **Get this from your OAuth App**  
    

    In addition to this, you need to copy the authorization code grant flow redirect URI from the same blade where you enter the above details and set that as the Authorization Callback URL in your GitHub OAuth App.

    The corresponding ARM Template resources when exporting is the following

       {  
           "type": "Microsoft.ApiManagement/service/authorizationServers",  
           "apiVersion": "2021-08-01",  
           "name": "[concat(parameters('service_integration_common_apim_name'), '/github-oauth2-0-app')]",  
           "dependsOn": [  
               "[resourceId('Microsoft.ApiManagement/service', parameters('service_integration_common_apim_name'))]"  
           ],  
           "properties": {  
               "displayName": "GitHub OAuth2.0 App",  
               "clientRegistrationEndpoint": "https://github.com/",  
               "authorizationEndpoint": "https://github.com/login/oauth/authorize",  
               "authorizationMethods": [  
                   "GET"  
               ],  
               "clientAuthenticationMethod": [  
                   "Body"  
               ],  
               "tokenBodyParameters": [],  
               "tokenEndpoint": "https://github.com/login/oauth/access_token",  
               "supportState": false,  
               "grantTypes": [  
                   "authorizationCode"  
               ],  
               "bearerTokenSendingMethods": [  
                   "authorizationHeader"  
               ],  
               "clientId": "<Client ID of your App>"  
           }  
       }  
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.