Skip to content

Instantly share code, notes, and snippets.

@xtiannyeto
Created September 20, 2021 12:18
Show Gist options
  • Save xtiannyeto/e608f4634e8a0a1780347be8a3a33f23 to your computer and use it in GitHub Desktop.
Save xtiannyeto/e608f4634e8a0a1780347be8a3a33f23 to your computer and use it in GitHub Desktop.
Export a method which return an instance with any config
export async function installGoogleAuth(options: any): Promise<any> {
// set config
let GoogleAuthConfig: any = null;
const GoogleAuthDefaultConfig = {
scope: 'profile email'
};
let prompt = 'select_account';
if (typeof options === 'object') {
GoogleAuthConfig = Object.assign(GoogleAuthDefaultConfig, options);
if (options.scope) {
GoogleAuthConfig.scope = options.scope;
}
if (options.prompt) {
prompt = options.prompt;
}
if (!options.clientId) {
// tslint:disable-next-line
console.warn('clientId is required');
}
} else {
// tslint:disable-next-line
console.warn('invalid option type. Object type accepted only');
}
await googleAuth.load(GoogleAuthConfig, prompt);
return googleAuth;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment