1

I am trying to automate creating the user in azure devops by writing a python script for that. I used the python client API of azure-devops for this purpose.

As of now, the authentication is done using a personal access token(PAT) :

from azure.devops.connection import Connection
from msrest.authentication import BasicAuthentication

personal_access_token = <myPAT>
organization_url = 'https://dev.azure.com/<myOrganization>'

# Create a connection to the org
credentials = BasicAuthentication('', personal_access_token)
connection = Connection(base_url=organization_url, creds=credentials)

Actually, I have a script that uses Graph API which authenticates to Azure AD via ADAL. That means I already have an application registered in our Azure AD which was created to use Graph API.

Can I use this application and it's client ID to authenticate to Azure DevOps services? How can use this authentication method with Python client API?

Does this article about OAuth 2.0 authentication method point to the same? : https://learn.microsoft.com/en-us/azure/devops/integrate/get-started/authentication/oauth?toc=%2Fazure%2Fdevops%2Forganizations%2Ftoc.json&bc=%2Fazure%2Fdevops%2Forganizations%2Fbreadcrumb%2Ftoc.json&view=azure-devops#register-your-app

I got confused as it says to create an app in azure devops, not in azure AD.

Could anyone help me by clarifying this and explaining the steps to do this authentication, if possible?

AnjK
  • 2,887
  • 7
  • 37
  • 64
  • why are you confused? just follow that tutorial? – 4c74356b41 Jun 12 '19 at 05:22
  • I am confused about creating the app again. Because I already have an application created in Azure AD. I need to know that if I could use the client-ID of that application to authenticate. If yes, how to do that with python client API of azure devops? – AnjK Jun 12 '19 at 05:28
  • I think for oAuth auth - no, you have to create Azure Devops app. https://learn.microsoft.com/en-us/rest/api/azure/devops/?view=azure-devops-rest-5.0#create-the-request – 4c74356b41 Jun 12 '19 at 05:35
  • But this sample says to register an app in Azure AD: https://github.com/microsoft/azure-devops-auth-samples/tree/master/ManagedClientConsoleAppSample – AnjK Jun 12 '19 at 05:45
  • thats not an oAuth example: https://github.com/microsoft/azure-devops-auth-samples/tree/master/OAuthWebSample – 4c74356b41 Jun 12 '19 at 05:47
  • That means what I need is not OAuth Authentication! – AnjK Jun 12 '19 at 06:00
  • Possible duplicate of [Use Azure AD token to authenticate with Azure DevOps](https://stackoverflow.com/questions/52896114/use-azure-ad-token-to-authenticate-with-azure-devops) a. You also might take a look at this sample https://github.com/microsoft/azure-devops-auth-samples/tree/master/JavascriptWebAppSample – Mohit Verma Jun 13 '19 at 12:28

0 Answers0