Authentication in Azure Devops
See original GitHub issueHi,
I want to use SDK inside a pipeline task. But I get token in another task as follow:
$token= $( az account get-access-token --resource=https://management.azure.com --query accessToken) Write-Host("##vso[task.setvariable variable=api-token;issecret=true]$token")
Is there anyway to use this token with SDK? Because I get token with service connection and I don’t store client and tenant info in environment variables.
Any advice would be appreciated.
Best
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Guidance for authentication - Azure DevOps - Microsoft Learn
A: The best practice is to have different authentication paths for Azure DevOps Server and Azure DevOps Services. You can use the requestContext ......
Read more >About security, authentication, and authorization
Authentication verifies an account identity based on the credentials provided when they sign into Azure DevOps. These systems integrate with and ...
Read more >Use personal access tokens - Azure DevOps | Microsoft Learn
A personal access token contains your security credentials for Azure DevOps. A PAT identifies you, your accessible organizations, and scopes of ...
Read more >Authorize access to REST APIs with OAuth 2.0 - Azure DevOps
Category Scope Name
Agent Pools vso.agentpools Agent Pools (read)
vso.agentpools_manage Agent Pools (read, manage)
vso.environment_manage Environment (read, manage)
Read more >Access your organization with Azure Active Directory
Azure DevOps no longer supports Alternate Credentials authentication since the beginning of March 2, 2020. If you're still using Alternate ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@mccoyp A million thanks!
Hi @anotherancientalien, thank you for opening an issue and providing additional information! If you’d like to use the access token directly and don’t need/want a credential to automatically refresh it, this sample from
azure-identity
should be what you’re looking for. After declaring a StaticTokenCredential type like the sample shows, you can do something like the following:Note that you will still have to provide the subscription ID and that the credential won’t be usable after the access token expires.