SPFx web-part authentication with REST API not secured with AAD

testuser7 271 Reputation points
2020-10-02T13:22:57.007+00:00

Hello,

We know that SPFx web-part is client-side solution.
The practical implication of this term is, whichever APIs this web-part is dependent on, that API must be registered and secured with Azure-AD.
It could be MS-graph or any other API and SPFx has APIs like AadHttpClient and MSGraphClient to invoke it on behalf of the same user who has signed into SharePoint.

However, if my web-part wants to access some API which is a std. OAuth API but this API is NOT registered with AAD. Instead, it is registered with some other identity solution eg., Okta, Can such API be invokable by my web-part ??

If it was MS-teams custom app, teams provide java-script API to open up a modal-popup and let the custom app finish the full OAuth authentication flow with Okta.

Thanks.

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,300 questions
0 comments No comments
{count} votes

Accepted answer
  1. Jerryzy 10,566 Reputation points
    2020-10-06T02:02:21.487+00:00

    Hi @testuser7 ,

    You are welcome :)

    You could refer the following documentation to achieve authentication with Azure AD in SPFX Solution:

    Connect to Azure AD-secured APIs in SharePoint Framework solutions

    SPFx: Calling AAD secured Azure Function on behalf of a user with AadHttpClient

    And if the reply above is helpful to this question, I suggest you could accept as answer so that it could be helpful to others in the forum.

    Thanks
    Best Regards

    0 comments No comments

3 additional answers

Sort by: Most helpful
  1. testuser7 271 Reputation points
    2020-10-05T18:36:16.12+00:00

    Thanks @Jerryzy-MSFT
    I can now at least stop thinking and designing in that direction.

    1 person found this answer helpful.
    0 comments No comments

  2. Jerryzy 10,566 Reputation points
    2020-10-05T02:24:41.843+00:00

    Hi @testuser7 ,

    Currently, SPFX is only available to autentcate with Azure AD, get access token and set related permission in Azure AD App, not supported other cloud platform.

    So other OAuth API can't be used in SPFX solution for authentication purpose.


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  3. testuser7 271 Reputation points
    2020-10-06T12:41:54.4+00:00

    Thanks @Jerryzy-MSFT

    The links that you sent me are great and I had followed it which put this question about third-party cloud identity platforms.

    Actually I have one point to discuss.
    As SPFx and Teams custom development is very comparable, there is one aspect of teams custom-tab which is really confusion me and I am still waiting for the answer.

    If you could eyeball https://learn.microsoft.com/en-us/answers/questions/106689/authentication-in-microsoft-teams-custom-apps-tabs.html, and clarify my doubt, that would be really helpful.

    Thanks.

    0 comments No comments