I'm trying to setup dependabot on azure devops on my repo. Below is my yml file:
version: 2
updates:
- package-ecosystem: 'nuget'
directory: '/'
target-branch: 'dev'
open-pull-requests-limit: 10
ignore:
- dependency-name: 'Microsoft.Extensions.Caching.SqlServer'
schedule:
interval: 'daily'
# Check for npm updates on Sundays
day: "sunday"
time: "09:00"
timezone: "America/Los_Angeles"
# Add reviewers
reviewers:
- "my-email"
# Labels on pull requests for security and version updates
labels:
- "npm dependencies"
However, I got the unauthorized error.
Failed to resolve user id: Error: Request to 'https://vssps.dev.azure.com/_apis/identities' failed: 401 Unauthorized
Based on the error, it seems like I don't or have not setup permission correctly for my account on the repo ??? If so, how do I give my account proper permission ?
Thank you.
According to the error message, the task is sending request to this API Identities - Read Identities to resolve the identity information of use reviewers. From the API scope, it should have the vso.identity
scope to grant the ability to read identities and groups.
It seems that when you are using the dependabot@V2
task in the pipeline, you are using the Task Parameter azureDevOpsAccessToken
to avoid using permissions for the Build Service account either because you cannot change its permissions or because you prefer that the Pull Requests be done by a different user.
In this case, you should give the personal access token the identity read permission and code read&write permission.
The test yaml to reproduce the error:
trigger:
- none
pool:
vmImage: ubuntu-latest
steps:
- task: dependabot@2
inputs:
azureDevOpsAccessToken: '$(pat)'
displayName: 'Dependabot'
Using PAT without the identity read permission :
Using PAT with the identity read permission :