You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 4, 2021. It is now read-only.
I am trying to convert the ADAL based example for Non Interactive Pat Generation to MSAL.
It looks like AAD is providing me a valid access token to the Azure DevOps REST API.
But when I try to connect it throws the following exception: VssUnauthorizedException: VS30063: You are not authorized to access https://spsprodeus24.vssps.visualstudio.com.
Program.cs is as follows:
MSAL program.cs
usingMicrosoft.Identity.Client;usingMicrosoft.VisualStudio.Services.Client;usingMicrosoft.VisualStudio.Services.DelegatedAuthorization;usingMicrosoft.VisualStudio.Services.DelegatedAuthorization.Client;usingMicrosoft.VisualStudio.Services.WebApi;usingSystem;usingSystem.Net;usingSystem.Security;usingSystem.Threading.Tasks;namespaceNonInteractivePatGenerationSampleMsal{classProgram{asyncstaticTaskMain(string[]args){varusername="[email protected]";varpassword=newNetworkCredential("","password").SecurePassword;varaadApplicationID="4f381a56-xxxx-xxxx-xxxx-redacted";// Created when you register an AAD application: https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-integrating-applications.varclient=PublicClientApplicationBuilder.Create(aadApplicationID).WithAuthority("https://login.microsoftonline.com/1fea1d7a-95b0-4ebc-b422-bcc75a77c9a0/").Build();varscopes=newstring[]{"https://app.vssps.visualstudio.com/user_impersonation"};varresult=awaitclient.AcquireTokenByUsernamePassword(scopes,username,password).ExecuteAsync();vartoken=newVssAadToken("Bearer",result.AccessToken);varvstsCredential=newVssAadCredential(token);varconnection=newVssConnection(newUri("https://dev.azure.com/carlintveld"),vstsCredential);varvsoclient=connection.GetClient<DelegatedAuthorizationHttpClient>();// the following invocation throws the exception:varpat=vsoclient.CreateSessionToken(displayName:"Generated by sample code",tokenType:SessionTokenType.Compact,scope:"vso.work").Result;Console.WriteLine(pat.Token);}}}
What do I need to do to fix this?
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I am trying to convert the ADAL based example for Non Interactive Pat Generation to MSAL.
It looks like AAD is providing me a valid access token to the Azure DevOps REST API.
But when I try to connect it throws the following exception:
VssUnauthorizedException: VS30063: You are not authorized to access https://spsprodeus24.vssps.visualstudio.com.
Program.cs is as follows:
MSAL program.cs
What do I need to do to fix this?
The text was updated successfully, but these errors were encountered: