* Loads the Google Sign-In API. * * This function is used in two places. * 1. The publisher's Google Sign-In iframe. * 2. (Optional) Demos that allow users to sign out. * * @return {!Promise}
()
| 2547 | * @return {!Promise} |
| 2548 | */ |
| 2549 | function configureGoogleSignIn() { |
| 2550 | // Wait for Google Sign-In API. |
| 2551 | return ( |
| 2552 | new Promise((resolve) => { |
| 2553 | const apiCheckInterval = setInterval(() => { |
| 2554 | if (!!self.gapi) { |
| 2555 | clearInterval(apiCheckInterval); |
| 2556 | resolve(); |
| 2557 | } |
| 2558 | }, 50); |
| 2559 | }) |
| 2560 | // Load Auth2 module. |
| 2561 | .then(() => new Promise((resolve) => self.gapi.load('auth2', resolve))) |
| 2562 | // Specify "redirect" mode. It plays nicer with webviews. |
| 2563 | .then( |
| 2564 | () => |
| 2565 | // Only initialize Google Sign-In once. |
| 2566 | self.gapi.auth2.getAuthInstance() || self.gapi.auth2.init() |
| 2567 | ) |
| 2568 | ); |
| 2569 | } |
| 2570 | |
| 2571 | /** |
| 2572 | * Calls Swgjs. |
no test coverage detected