async function getUserAccessTokenImpl()

in space-slack-sync/client/src/app/service/spaceAuth.ts [23:43]


async function getUserAccessTokenImpl(askForConsent: boolean): Promise<string | null> {
    let tokenResponse: GetUserTokenResponse = await new Promise((resolve) => {
        const channel = new MessageChannel();
        channel.port1.onmessage = e => resolve(e.data);
        window.parent.postMessage({
            type: "GetUserTokenRequest",
            permissionScope: "global:Chat.BrowseChannels global:Channel.ViewChannel",
            askForConsent: askForConsent
        }, "*", [channel.port2]);
    });


    if (tokenResponse != null && tokenResponse.token != null) {
        spaceServerUrl = tokenResponse.serverUrl;
        spaceDomain = new URL(spaceServerUrl).host;
        setUserToken(tokenResponse.token);
        return tokenResponse.token;
    }

    return null;
}