Skip to content

SPFx & Azure Function : How to open ClientContext using user's bearer token? #2984

@spplante

Description

@spplante

Category

  • Question
  • Typo
  • Bug
  • Additional article idea

Expected or Desired Behavior

Following the Connect to Azure AD-secured APIs in SharePoint Framework solutions tutorial, once SPFx handled the authentication of the current user to my Function App, I would simply like to get an access token which I could use to open a ClientContext with and perform operations in SharePoint Online on behalf of the user.

Observed Behavior

I was able to create with success an SPFx extension which authenticates and calls my Azure Function using the AadHttpClient, so far so good. In my C# Azure Function, I can trace the current user's name and I do see the current user correctly, so the whole SPFx / AAD App / Azure Function authentication process works as expected.

The only step I am missing is to open a CSOM ClientContext using the currently logged in user. There is no official documentation on this whatsoever, I expected the bearer token to be available in the function's parameters but it doesn't look as easy.

The article above does not cover the azure side at all, it only shows the JavaScript side...

Any help would be appreciated, thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:authCategory: Authentication (Azure AD / etc)type:questionQuestion... if answered, will be tagged as such.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions