I have a small problem. I'm trying to get the tanant id. I tried to use code below but can only get project id.
import * as SDK from "azure-devops-extension-sdk";
import { CommonServiceIds, IProjectPageService } from "azure-devops-extension-api";
const projectService = await SDK.getService<IProjectPageService>(CommonServiceIds.ProjectPageService);
const project = await projectService.getProject();
Any ideas ?
CodePudding user response:
You can find tenant ID
in Domain property of below DevOps API call response regarding Identities:
GET https://vssps.dev.azure.com/{organization}/_apis/identities?searchFilter=General&filterValue=<Azure AD username>&queryMembership=None&api-version=7.0
I tried to reproduce the same in my environment via Postman and got below results
To create new Personal access token (PAT), you can find below steps in your DevOps portal:
I generated one PAT token
with full access for my DevOps organization like below:
When I ran below query including PAT token in Postman, I got tenant ID
in response successfully like below:
GET vssps.dev.azure.com/{organization}/_apis/identities?searchFilter=General&filterValue=<Azure AD user UPN>&queryMembership=None&api-version=7.0
Response:
To confirm that, I checked the same in Azure DevOps portal and got same tenant ID like this:
Reference: IdentitySelf interface | Microsoft