* Get access token * @param {String} email * @param {Array} scopes * @param {Function} beforeAuth - called before new authorization request is started * @param {Function} afterAuth - called after successful authorization request * @return {String}
({email, legacyGsuite, scopes = [gmail.GMAIL_SCOPE_READONLY, gmail.GMAIL_SCOPE_SEND], beforeAuth, afterAuth} = {})
| 182 | * @return {String} |
| 183 | */ |
| 184 | async getAccessToken({email, legacyGsuite, scopes = [gmail.GMAIL_SCOPE_READONLY, gmail.GMAIL_SCOPE_SEND], beforeAuth, afterAuth} = {}) { |
| 185 | const accessToken = await this.checkAuthorization({email, scopes}); |
| 186 | if (accessToken) { |
| 187 | await this.checkLicense({email, legacyGsuite}); |
| 188 | return accessToken; |
| 189 | } |
| 190 | if (beforeAuth) { |
| 191 | beforeAuth(); |
| 192 | } |
| 193 | this.openAuthorizeDialog({email, legacyGsuite, scopes}); |
| 194 | return new Promise((resolve, reject) => this.authorizationRequest = {resolve, reject, afterAuth}); |
| 195 | } |
| 196 | |
| 197 | async onAuthorize({email, legacyGsuite, scopes, forcePicker = false}) { |
| 198 | try { |
no test coverage detected