-
Notifications
You must be signed in to change notification settings - Fork 198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Azure B2C authentication from SPFX App Teams #2669
Comments
@Ben-Oops - Thank you for bringing this issue to our attention. We will look into it and get back to you shortly. |
@Ben-Oops thanks for providing a great level of detail in your question, including a code snippet! You're right that solution1 won't work for pop-up blocking reasons, which is why the authentication.authenticate function exists, like you are using in solution2. In solution 2, is the page that you're directing the pop-up to ( You can see a visual overview of this expected flow here: From the code that I see, it looks like the page that is getting launched in the authentication pop-up might not be making the appropriate teamsjs calls to communicate the result back to the original tab page. What do you think? |
Yes, you're absolutely right, that's the source of my problem i guess. My redirection page as you can see don't call authentication.notifySuccess. Why ? Because it's a native page which is stored inside /_layouts/15/teamslogon.aspx and i can't include custom code in it. I don't know which let's say "native redirection address" I can set up to be able to call this authentication.notifySuccess on my pop-up. Does it mean that i need to create a proxy somewhere for example a sharepoint page in order to be able to call authentication.notifySuccess ? |
Yes, you'll need to have some page where you can write custom code that calls |
Thanks for your answer. Unfortunately as it's an SPFx project based on this article i don't really know what route/path i can provide to be able to do this. https://learn.microsoft.com/en-us/microsoftteams/platform/sbs-gs-spfx?tabs=vscode%2Cviscode I don't really have a path of my application as it's handle by Teams. If i take a look to my Teams Manifest app, my content url is like this. |
Thanks again for your help. I was able to get Teams Desktop to work, but now I can't get it to work in Teams Web mode. I have the following error after the execution of authentication.notifySuccess. I saw this post https://github.com/OfficeDev/microsoft-teams-library-js/issues/1779 related to this issue but it doesn't help me. You can find below the related code i used to called authentication.notifySuccess.
|
Hmm, I'm not sure what might be causing that. Is that "TEAMS AUTH Error" string somewhere in your code or is it coming from Teams? Is Enabling TeamsJS client logging may help track down what's going on after you call BTW you may only be doing this for testing but you shouldn't send tokens back via |
Context:
In the context of a POC, I need to make calls to APIs from an SPFX App Teams hosted in my tenant using an Azure AD B2C to authenticate. I create an IDP (Identity Provider) to add my tenant in Azure B2C. To authenticate we use OAuth 2.0 Open ID Connect with Authorization Code flow.
Repro Step
Solution 1: Use @azure/msal-browser SDK for authentication
It works in Teams Web but not in Teams Desktop because it does not allow to open pop-up. See below.
I think there is no way to authorize po-up in Teams Desktop so i tried Solution 2 below.
Solution 2: Use @microsoft/teams-js SDK for authentication
This time the pop-up is now displayed correctly in Teams Desktop but I can't complete authentication in both Teams Desktop and Web. I do receive the authorisation code but it is not intercepted by the Teams connection SDK and is therefore not sent to the /token endpoint to retrieve the authentication token. I use the same redirect URL as the one used with @azure/msal-browser SDK
Redirect URL: https://[tenantname].sharepoint.com/_layouts/15/teamslogon.aspx
As you can see in Step 2 I'm stuck on this screen with no way of recovering my access token. If anyone can help me with this it would be greatly appreciated. Thank you very much.
The text was updated successfully, but these errors were encountered: