locked
Using Identitity token to authenticate to REST API and SharePoint ClientContext RRS feed

  • Question

  • 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.

    EG
    var userClaims = User.Identity as System.Security.Claims.ClaimsIdentity;
    string accessToken = userClaims?.FindFirst( "access_token")?.Value;

    Can anyone point me to a tutorial / code that lets me use the userClaims to provide authentication to the following: 

    C# >>> http post or get  via WebClient / HttpClient ? request or equivalent 

    C# >>> SharePoint Online ClientContext   

    Jquery / Javascript / AngularJS Http get / post

    Thank you.   

    PS.If think that this is relevant for this forum, please do advise what forum it should go in.

    Thanks again.

    regards Richard


    Richard

    Wednesday, April 15, 2020 11:06 AM

All replies

  • Please post questions related to web development in the ASP.NET forums.

    As for the usage of HttpClient you have to pass any user credentials in the format required by the remote server. That is generally handled using the the Authorization header (basic, oauth, etc). Example post over on ASP.NET forums.

    However claims are generally handled using JWT which requires you to attach cookies instead. For that you have to set the CookieContainer on the underlying handler (a serious pain I know) but you cannot do that directly. This post discusses how to set cookies.

    Questions related to SharePoint would need to be posted over at SharePoint's forums.


    Michael Taylor http://www.michaeltaylorp3.net

    Wednesday, April 15, 2020 1:30 PM
  • Thank you


    Richard

    Wednesday, April 15, 2020 2:06 PM