In the link below it is suggested to use Google Auth Lib
, but the github
link provided does not refer to any javascript library:
As far as I know I cannot use the Code FLow
as it needs a redirect URL. How should I get Access Token
from Google
in Microsoft Word Add-In
?
In order to Login using Google
, Facebook
, etc you can use office-js-helpers
:
Install it using npm
:
npm install --save @microsoft/office-js-helpers
And in your code, inside of 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);
}
That's it!