Advertisement
Guest User

Untitled

a guest
Aug 21st, 2017
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. const google = require('googleapis');
  2.  
  3. google.auth.getApplicationDefault(function (err, authClient, projectId) {
  4. if (err) {
  5. console.log('Authentication failed because of ', err);
  6. return;
  7. }
  8.  
  9. if (authClient.createScopedRequired && authClient.createScopedRequired()) {
  10. authClient = authClient.createScoped([
  11. 'https://www.googleapis.com/auth/siteverification'
  12. ]);
  13. }
  14.  
  15. const siteVerification = google.siteVerification({
  16. version: 'v1',
  17. auth: authClient
  18. });
  19.  
  20. siteVerification.webResource.get({
  21. id: customDomain.name
  22. }, {}, function (err, data) {
  23. if (err) {
  24. console.log('siteVerification get error:', err);
  25. } else {
  26. console.log('siteVerification result:', data);
  27. }
  28. });
  29. });
  30.  
  31. siteVerification get error: { Error: A Forbidden error was returned while attempting to retrieve an access token for the Compute Engine built-in service account. This may be because the Compute Engine instance does not have the correct permission scopes specified. Insufficient Permission
  32. at Request._callback (/user_code/node_modules/googleapis/node_modules/google-auth-library/lib/transporters.js:85:15)
  33. at Request.self.callback (/user_code/node_modules/googleapis/node_modules/request/request.js:188:22)
  34. at emitTwo (events.js:106:13)
  35. at Request.emit (events.js:191:7)
  36. at Request.<anonymous> (/user_code/node_modules/googleapis/node_modules/request/request.js:1171:10)
  37. at emitOne (events.js:96:13)
  38. at Request.emit (events.js:188:7)
  39. at IncomingMessage.<anonymous> (/user_code/node_modules/googleapis/node_modules/request/request.js:1091:12)
  40. at IncomingMessage.g (events.js:292:16)
  41. at emitNone (events.js:91:20)
  42. code: 403,
  43. errors:
  44. [ { domain: 'global',
  45. reason: 'insufficientPermissions',
  46. message: 'Insufficient Permission' } ] }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement