OfficeDev / office-js-helpers

[ARCHIVED] A collection of helpers to simplify development of Office Add-ins & Microsoft Teams Tabs
MIT License
126 stars 56 forks source link

`plus.me` scope does not return email of user #119

Open alirezastack opened 5 years ago

alirezastack commented 5 years ago

The problem I faced is that when a token is generated based on plus.me and that token is given to google via our server. The token does not return user email address:

/**
     * Register Google Implicit OAuth.
     * If overrides is left empty, the default scope is limited to basic profile information.
     *
     * @param {string} clientId ClientID for the Google App.
     * @param {object} config Valid Endpoint configuration to override the defaults.
     * @return {object} Returns the added endpoint.
     */
    EndpointStorage.prototype.registerGoogleAuth = function (clientId, overrides) {
        var defaults = {
            clientId: clientId,
            baseUrl: 'https://accounts.google.com',
            authorizeUrl: '/o/oauth2/v2/auth',
            resource: 'https://www.googleapis.com',
            responseType: 'token',
            scope: 'https://www.googleapis.com/auth/plus.profile.emails.read',
            **// scope: 'https://www.googleapis.com/auth/plus.me',**
            state: true
        };
        var config = __assign({}, defaults, overrides);
        return this.add(DefaultEndpoints.Google, config);
    };

I changed plus.me to plus.profile.emails.read and I could get user's email address. Why this scope is set and is there any chance to change this scope to plus.profile.emails.read?

sumurthy commented 5 years ago

Could you clarify if this is Office-js-helpers related? When you say you couldn't get the email address back, can you specify where you are unable to receive?

alirezastack commented 5 years ago

@sumurthy yes it is related to office.js helpers. I have provided the code from office library and based on the scope in office-js helpers it gives a token that return insufficient account information.

For now I use the below scope to get user email address and name:

https://www.googleapis.com/auth/ plus.me https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email