Derek Smith
Derek Smith

Reputation: 863

Teams tab authentication

I'm trying to figure out how to use the microsoftTeams.authentication.authenticate() function but I'm really confused. When I call the function, a new tab is opened in my browser (Chrome) window and not within Teams itself. Is this normal behavior? The authentication works and redirects to a callback url where I call the microsoftTeams.authentication.notifySuccess() function but it doesn't get back to the microsoftTeams.authentication.authenticate() success callback (always hits the failure callback). Is this an issue with validDomains? I'm pretty lost. Any help would be great! Thank you.

microsoftTeams.authentication.authenticate({
    url: "/auth",
    width: 500,
    height: 500,
    successCallback: () => {
        alert("auth success")
        // Redirect to app
        window.location.href = "/app"
    },
    failureCallback: () => {
        alert("auth failure")
    }
})

Upvotes: 4

Views: 4411

Answers (1)

Derek Smith
Derek Smith

Reputation: 863

I figured it out.

I made the mistake of calling the microsoftTeams.authentication.authenticate() function on page load instead of on some user interaction like a login button click.

Reference: "Add UI to your configuration or content page to enable the user to sign in when necessary. You should not drive the authentication pop-up without user action, because this is likely to trigger the browser's pop-up blocker."

Upvotes: 3

Related Questions