UNPKG

kayla-normal-repo

Version:

test npm manifest

54 lines (48 loc) 1.77 kB
const {auth,OAuth2Client,Compute} = require('google-auth-library'); // const {google} = require('googleapis'); /** * Instead of specifying the type of client you'd like to use (JWT, OAuth2, etc) * this library will automatically choose the right client based on the environment. */ async function main() { // var GoogleAuth; // GoogleAuth = gapi.auth2.getAuthInstance(); // console.log(GoogleAuth); // var user = GoogleAuth.currentUser.get(); // console.log(user); console.log("STEP 1") const projectId = await auth.getProjectId(); console.log(projectId); // const oauth2Client = new OAuth2Client( // "32555940559.apps.googleusercontent.com", // "ZmssLNjJy2998hD4CTg2ejr2", // "http://localhost:3000/oauth2callback" // ); // const tokens = await oauth2Client.getToken(code); // const auth2 = await google.auth.getClient({ // Scopes can be specified either as an array or as a single, space-delimited string. // scopes: ['https://www.googleapis.com/auth/cloud-platform'] // }); // console.log(tokens); // try { const client = await auth.getClient({ scopes: 'https://www.googleapis.com/auth/cloud-platform' }); // } // catch (err) { // console.log("Not app default creds.") // } console.log("STEP 2"); client.setCredentials(client.credentials); console.log(client.credentials); console.log(await client.getRequestHeaders()); // const projectId = await auth.getProjectId(); // const url = `https://www.googleapis.com/dns/v1/projects/${projectId}`; // console.log("STEP 3"); // const res = await client.request({ url }); // console.log("STEP 4"); // console.log(res.data); } main().catch(console.error); // 32555940559.apps.googleusercontent.com // ZmssLNjJy2998hD4CTg2ejr2