OfficeDev / office-js

A repo and NPM package for Office.js, corresponding to a copy of what gets published to the official "evergreen" Office.js CDN, at https://appsforoffice.microsoft.com/lib/1/hosted/office.js.
https://learn.microsoft.com/javascript/api/overview
Other
670 stars 95 forks source link

Office SSO GetAccessToken Error on mobile browsers (Edge,Safari) #3719

Open Kelarann opened 11 months ago

Kelarann commented 11 months ago

I have simply Office Excel Web Addin from Visual Studio 2022 which is my base code for development. I have implemented one function which is based on authentication with Office SSO and then Behalf authentication flow on the server side, but first step matters the most - Fetch Access token from Office Context. Here is fragment of my code:

async function GetAccessToken() {
        try {
            console.log("Start to fetch behalf token");
            var behalfToken = "";
            var accessToken = "";
            await Office.auth.getAccessToken({
                allowSignInPrompt: true,
                allowConsentPrompt: true,
                forMSGraphAccess: true
            }).then(officeResponse => {
                if (officeResponse.error) {
                    console.log(response);
                } else {
                    behalfToken = officeResponse
                }
            });
            console.log("Got behalf token");

            console.log("Fetch access token")
            const url = "https://myazurewebiste-site1.atempurl.com/onbehalf"
            const headers = { 'Authorization': `${behalfToken}` };

            accessToken = await Http("GET", url, headers)

            console.log("We got accessToken")

            return accessToken.access_token;

        } catch (error) {
            console.error("Wystąpił błąd:", error.message);
        }
    }

This is method responsible for office auth. Its works perfectly on desktop and browser version of Excel but only od WINDOWS or MacOS. On EDGE Mobile on iPadOS it's not working or safari same thing. Didnt tried other tablets or phones.

Log from Mobile Edge here : Console Log Mobile Edge

Kelarann commented 8 months ago

Any movement on this?:)

Kelarann commented 1 month ago

Guys ?