gapi . load ( 'client' , ( ) => { async function run ( ) { } /** now we can use gapi.client */ gapi . client . load ( 'firestore' , 'v1' , ( ) => { /** now we can use gapi.client.firestore */ /** don't forget to authenticate your client before sending any request to resources: */ /** declare client_id registered in Google Developers Console */ const client_id = '<<PUT YOUR CLIENT ID HERE>>' ; const scope = [ 'https://www.googleapis.com/auth/cloud-platform' , 'https://www.googleapis.com/auth/datastore' , ] ; const immediate = false ; gapi . auth . authorize ( { client_id , scope , immediate } , ( authResult ) => { if ( authResult && ! authResult . error ) { /** handle successful authorization */ run ( ) ; } else { } } ) ; } ) ; } ) ;