OneDrive / samples

Contains samples, scenarios, and guidance for integrating with OneDrive and SharePoint drives, drive items, and files.
MIT License
56 stars 56 forks source link

Production mode loginPopup issue: BrowserAuthError - User Cancelled Flow #58

Open Asteryx21 opened 1 year ago

Asteryx21 commented 1 year ago

Issue We've implemented the File Picker for both personal and business accounts by following the documentation and the samples given in the repository. While everything works as intended (Screenshot 1) in development mode (localhost), the issue comes to production (Screenshot 2 & 3). When the user opens the Microsoft login popup appears and we instatly get the error: BrowserAuthError: user_cancelled: User cancelled the flow. The popup window then redirects to the actual web app we have and not to the coresponding OneDrive/ SharePoint.

The error comes to that line:

try {
resp = await app.loginPopup(authParams);
} catch (error) {
console.log(error) 
}

To Reproduce Steps to reproduce the behavior: Followed the Documentation provided here and samples examples from this repository.

Expected behavior The app in production mode to work as in development mode. Once the user signs in the Microsoft popup the "Picker" popup to show the OneDrive/SharePoint.

Screenshots Screenshot 1: Capture Screenshots 2 & 3: Capture2 Capture3

Details In my Azure Portal App I've given the following access: Capture4

Picker configuration options:

const params = {
        sdk: "8.0",
        entry: {
            oneDrive: {
                files: {},
            },
        },
        authentication: {},
        messaging: {
            origin: window.location.href,
            channelId: "54327",
        },
        typesAndSources: {
            mode: "files",
            filters: [".xlsx", ".csv"],
            pivots: {
                oneDrive: true,
                recent: true,
                sharedLibraries: false,
            },
        },
    };

My msalParams and authParams:

    const msalParams = {
        auth: {
            authority: "https://login.microsoftonline.com/",
            clientId: MY_CLIENT_ID,
            redirectUri: window.location.href,
        },
    };
    const authParams = {};
        if (accountType === "business") {
        authParams.scopes = [
            "user.read",
            "User.Read",
            "Files.Read",
            "Files.Read.All",
            "Files.Read.Selected",
            "Files.ReadWrite",
            "offline_access",
        ];
        msalParams.auth.authority += "common/";
    } else if (accountType === "consumers") {
        authParams.scopes = ["OneDrive.ReadWrite"];
        msalParams.auth.authority += "consumers/";
    }
JCrew0 commented 10 months ago

Hey @Asteryx21, I'm going through and looking at some of the older issues. Did anyone ever address this or did you come up with a solution? If not, I can try to take a look. Thanks!

Asteryx21 commented 10 months ago

Hey @JCrew0 and happy new year. I didn't manage to find any solution. I would really appreciate you taking a look.