Last post Apr 17, 2020 01:23 AM by yij sun
Apr 15, 2020 02:15 PM|Richard Scannell|LINK
I have used the following tutorial
https://docs.microsoft.com/en-us/azure/active-directory/develop/quickstart-v2-aspnet-webapp to authenticate to Azure AD and to retrieve a set of claims about my credential.
var userClaims = User.Identity as System.Security.Claims.ClaimsIdentity;
string accessToken = userClaims?.FindFirst( "access_token")?.Value;
Please can anyone point me to a tutorial / code that lets me use the userClaims to provide an Authentication token to the following:
1 C# >>> http post or get via WebClient / HttpClient ? request or equivalent
2 C# >>> SharePoint Online ClientContext
PS.If think that this is relevant for this forum, please do advise what forum it should go in.
Apr 17, 2020 01:23 AM|yij sun|LINK
Hi Richard Scannell,
Accroding to your description,you could get access_token in the context about C# httpclient.
More details,you could refer to below codes:
var accessToken = await HttpContext.GetTokenAsync("access_token");
var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
var content = await client.GetStringAsync("http://localhost:5001/identity");
More details,you could refer to below article: