首页 文章

如何使用Microsoft Word加载项登录Google

提问于
浏览
0

在下面的链接中建议使用 Google Auth Lib ,但提供的 github 链接不引用任何JavaScript库:

据我所知,我不能使用 Code FLow ,因为它需要一个重定向URL . 我应该如何从 Microsoft Word Add-In 中的 Google 获得 Access Token

1 回答

  • 0

    要使用 GoogleFacebook 等登录,您可以使用 office-js-helpers

    使用 npm 安装它:

    npm install --save @microsoft/office-js-helpers
    

    在您的代码中, Office.initialize 内:

    Office.initialize = function (reason) {
        //...
        // This to inform the Authenticator to automatically close the authentication dialog once the authentication is complete.
        if (OfficeHelpers.Authenticator.isAuthDialog()) return;
    
        // register Google endpoint using
        authenticator.endpoints.registerGoogleAuth('GOOGLE-CLIENT-ID');
        authenticator
             .authenticate(OfficeHelpers.DefaultEndpoints.Google)
             .then(function (token) { console.log('_GOOGLE_TOKEN: ', token); })
             .catch(OfficeHelpers.Utilities.log);
    }
    

    而已!

相关问题