Azure DevOps – REST APIs – Part 2 – Creating Personal Access Tokens (PATs)

Azure DevOps - Personal Access Token
Azure DevOps - Personal Access Token

Hi All,

LIFE IS BEAUTIFUL 🙂 I hope we all are safe 🙂 STAY SAFE, STAY HEALTHY,  STAY HOME 🙂

Background: We have started discussing Azure DevOps. In last 8 articles of Azure DevOps we discussed

In this article we will move ahead and will discuss how to create Personal Access Token (PAT). We need PATs for authenticating Azure DevOps. In one of the upcoming article we need to discuss – calling REST APIs programmatically where we need Personal Access Token for authenticating DevOps.

Take away from this article: At the end of this article we will got to know about

  • What is Personal Access Token (PAT)
  • How to create Personal Access Token (PAT)

What is Personal Access Token (PAT) :

  • Personal Access Token (PAT) is mechanism to authenticate Azure DevOps
  • PAT is the alternative for using Password to authenticate Azure DevOps
  • We will generate PAT for accessing specific resource (scope) like WorkItems, builds, activities and so on
  • PATs are used for accessing REST APIs

When to use Personal Access Token (PAT) to authenticate Azure DevOps / Scenario where PATs can be used for authentication :

  • When we need to call Azure DevOps REST APIs programmatically
  • If sometime we works with third party tools which don’t support Microsoft or Azure AD account, and we don’t want to share our credentials with this third party software then we have an option of using PATs
  • For smaller projects again PAT is the robust solution

Creating a PAT :

Azure DevOps - Creating Personal access tokens (PAT) - User Settings >> Personal access tokens
Fig : Azure DevOps – Creating Personal access tokens (PAT) – User Settings >> Personal access tokens
  • We will be navigated to Personal Access Tokens home page – https://dev.azure.com/<organization name>/_usersSettings/tokens, following figure shows the home page of Personal Access Tokens home page
Azure DevOps - Creating Personal access tokens (PAT) - PAT home page
Fig : Azure DevOps – Creating Personal access tokens (PAT) – PAT home page
  • On the PAT home page we have an option to create new token as shown in below Fig
Azure DevOps - Creating Personal access tokens (PAT) - PAT home page - Create a new personal access token dialog
Fig : Azure DevOps – Creating Personal access tokens (PAT) – PAT home page – Create a new personal access token dialog
  • We have various options on “Create a new personal access token” such as
    • Name of token
    • Expiration (UTC)
    • Scopes
  • Expiration (UTC) : defines the lifespan of PAT
    • We have 4 options for Expiration (UTC) as shown in below Fig
    • In last option “Custom defined“, we can specify expiration date till 1 year.
    • We can not set expiration for PAT beyond 1 year
 Azure DevOps - Creating Personal access tokens (PAT) - PAT home page - Create a new personal access token dialog - Expiration (UTC) options - life span of PAT
Fig : Azure DevOps – Creating Personal access tokens (PAT) – PAT home page – Create a new personal access token dialog – Expiration (UTC) options – life span of PAT
 Azure DevOps - Creating Personal access tokens (PAT) - PAT home page - Create a new personal access token dialog - Scopes
Fig : Azure DevOps – Creating Personal access tokens (PAT) – PAT home page – Create a new personal access token dialog – Scopes
Azure DevOps - Creating Personal access tokens (PAT) - PAT home page - Create a new personal access token dialog - Custom scopes
Fig : Azure DevOps – Creating Personal access tokens (PAT) – PAT home page – Create a new personal access token dialog – Custom scopes
  • Once we have details like Expiration, Scopes selection is in place we are ready to create PAT.
  • Please click on “Create” button as shown in above Fig.
  • If PAT created successfully then we have “Success!” dialog as shown in below Fig
Azure DevOps - Creating Personal access tokens (PAT) - PAT home page - Create a new personal access token dialog - PTA created successfully
Fig : Azure DevOps – Creating Personal access tokens (PAT) – PAT home page – Create a new personal access token dialog – PTA created successfully
  • Make sure we copy the PTA right away, please see the warning on “Success!” dialog as shown in above Fig
  • We have all the listing of PTAs – Personal Access Tokens on PTAs home page – https://dev.azure.com/<organization name>/_usersSettings/tokens as shown in below fig
  • On selection of respective PTA we can perform various operations like – “Revoke”, “Edit” and “Regenerate”. We will discuss each operation in depth in next upcoming articles.
Azure DevOps - Creating Personal access tokens (PAT) - PAT home page - listing the respective tokens and respective operations which can be performed
Fig : Azure DevOps – Creating Personal access tokens (PAT) – PAT home page – listing the respective tokens and respective operations which can be performed
  • We will also receive notification for addition of new PAT to our organization as shown in below Fig
Azure DevOps - Notification for successfully adding PAT to organization
Fig : Azure DevOps – Notification for successfully adding PAT to organization

References:

Next Article: On PATs we can perform various operations like – “Revoke”, “Edit” and “Regenerate”. We will discuss these operations and uses.

We have very good series going on Azure DevOps. Please have a look once –https://knowledge-junction.in/?s=Azure+DevOps

Thanks for reading 🙂 Feel free to discuss / comment / questions 🙂 SHARING IS CARING 🙂

Share In Teams:

Enjoy the beautiful life 🙂 Have a FUN 🙂 HAVE A SAFE LIFE 🙂 TAKE CARE 🙂

Prasham Sabadra

LIFE IS VERY BEAUTIFUL :) ENJOY THE WHOLE JOURNEY :) Founder of Knowledge Junction and live-beautiful-life.com, Author, Learner, Passionate Techie, avid reader. Certified Professional Workshop Facilitator / Public Speaker. Scrum Foundation Professional certificated. Motivational, Behavioral , Technical speaker. Speaks in various events including SharePoint Saturdays, Boot camps, Collages / Schools, local chapter. Can reach me for Microsoft 365, Azure, DevOps, SharePoint, Teams, Power Platform, JavaScript.

You may also like...

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: