Validate the azure-devops PAT

Viewed 916

I have created an PAT from azure devops. Now i have create a react app to handle all the api logics. I have a login screen now user need to enter the DEVOPS_TOKEN, ORGANISATION_NAME. How can i validate the user token at login. I couldn't find any api for validate the user.

Any suggestions would be helpful.

1 Answers

After a bit of investigation i found out a way to validate the user. There is an api that is available in Azure Devops: https://dev.azure.com/{ORGANISATION_NAME}/_apis/connectionData.

Need to pass the encoded token in header parameter that results the user authorization.

{
    "authenticatedUser": {
        "id": "123-13-131231231-123-123-123-123",
        "descriptor": "Microsoft.IdentityModel.Claims.ClaimsIdentity;123-13-131231231-123-123-123-123\\user@domain.com",
        "subjectDescriptor": "aad.Masdasdpadspoadsjpaodsjapodj",
        "providerDisplayName": "User Name",
        "isActive": true,
        "properties": {
            "Account": {
                "$type": "System.String",
                "$value": "user@domain.com"
            }
        },
        "resourceVersion": 2,
        "metaTypeId": 0
    },
    "authorizedUser": {
        "id": "123-13-131231231-123-123-123-123",
        "descriptor": "Microsoft.IdentityModel.Claims.ClaimsIdentity;123-13-131231231-123-123-123-123\\user@domain.com",
        "subjectDescriptor": "aad.Masdasdpadspoadsjpaodsjapodj",
        "providerDisplayName": "User Name",
        "isActive": true,
        "properties": {
            "Account": {
                "$type": "System.String",
                "$value": "user@domain.com"
            }
        },
        "resourceVersion": 2,
        "metaTypeId": 0
    },
    "instanceId": "123-13-131231231-123-123-123-123",
    "deploymentId": "123-13-131231231-123-123-123-123",
    "deploymentType": "hosted",
    "locationServiceData": {
        "serviceOwner": "123-13-131231231-123-123-123-123",
        "defaultAccessMappingMoniker": "PublicAccessMapping",
        "lastChangeId": 12313123,
        "lastChangeId64": 123123123
    }
}
Related