Skip to content
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

Copilot OAuth #11966

Open
mathihalli opened this issue Dec 20, 2024 · 3 comments
Open

Copilot OAuth #11966

mathihalli opened this issue Dec 20, 2024 · 3 comments
Assignees

Comments

@mathihalli
Copy link

Steps to reproduce

Now, try to access (via copilot) the app and it should prompt you to Sign in. When you click on the sign-in button, the login fails and you'll see this error in the console logs

Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('https://login.microsoftonline.com') does not match the recipient window's origin ('https://teams.microsoft.com').

Expected behavior

The sign-in should happen and the successful auth should've been posted to the Teams window

Actual behavior

The sign-in popup shows a blank screen and the console logs has this warning message:

Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('https://login.microsoftonline.com') does not match the recipient window's origin ('https://teams.microsoft.com').

Error details

The sign-in button was working till ~2 days ago

@sayali-MSFT
Copy link

Hello @mathihalli,
Thank you for your inquiry about your Teams app development issue! To assist you better, could you please provide the following details?

  1. Documentation Links: Any specific documentation you followed that relates to your problem.
  2. Teams Client Version: What version of the Teams client are you using?
  3. Code Snippets: Relevant code snippets that illustrate the issue.

This information will help us better understand the situation and provide a more accurate response.

@mathihalli
Copy link
Author

mathihalli commented Dec 20, 2024 via email

@sayali-MSFT
Copy link

@mathihalli -The error you're encountering, "Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('https://login.microsoftonline.com') does not match the recipient window's origin ('https://teams.microsoft.com')", indicates a mismatch between the target origin specified in the postMessage call and the origin of the recipient window.

  1. Ensure that the OAuth registration id and URLs in your plugin.json file are correctly set up.
  2. Make sure that the allowed origins for your OAuth app include both https://login.microsoftonline.com and https://teams.microsoft.com.
  3. If the authentication is being initiated from https://teams.microsoft.com, the redirect URI should also be on the same domain. Ensure the redirect URI in your OAuth configuration matches the origin from which the authentication is being initiated.
  4. Verify the postMessage call in your code. The target origin must precisely match the recipient window's origin. Here is an example of how to correctly use postMessage: window.postMessage(message, "https://teams.microsoft.com");
  5. Update Teams Toolkit: Ensure you are using the latest version of the Teams Toolkit. Some issues might have been resolved in newer versions.

Could you please also raise the issue here to seek guidance related to Teams Toolkit: -https://github.com/OfficeDev/teams-toolkit/issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants