question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hello,

I am currently getting the error:

{ [Error: Not Found] code: 404 errors: [ { domain: ‘global’, reason: ‘notFound’, message: ‘Not Found’ } ] }

When trying to use the calendar api using JWT. I am struggling to find this error message and how to debug this online. Please help! My code is the following:

jwtClient.authorize(function(err, tokens) {
  if (err) {
    console.log(err);
    return;
  }

  // Make an authorized request to list Drive files.
  calendar.events.list({ 
    auth: jwtClient,
    calendarId: calendarId,
    timeMin: (new Date()).toISOString(),
    maxResults: 100,
    singleEvents: true,
    orderBy: 'startTime' 
  }, function(err, resp) {
    // handle err and response
    console.log("===============")
    console.log(err)
    console.log(resp)
  });
});

The call works when i authorize via auth.OAuth2…

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:16 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
kunokdevcommented, Sep 12, 2016

I am trying to fetch all emails under our domain. I have all admin rights anda I created service account with Domain wide delegation. This is my code:

const google = require('googleapis');
const gmail = google.gmail('v1');
const directory = google.admin('directory_v1');
const scopes = [
  'https://www.googleapis.com/auth/gmail.readonly',
  'https://www.googleapis.com/auth/admin.directory.user.readonly'
];
const key = require('./service_key.json');

var authClient = new google.auth.JWT(
  key.client_email,
  null,
  key.private_key,
  scopes,
  null
);

authClient.authorize(function(err, tokens){
  if (err) {
    console.log(err);
    return;
  }

  directory.users.list(
    {
      auth: authClient,
      customer: 'my_customer',
      maxResults: 250,
      orderBy: 'email'
    }, (err, resp) => {
    if (err) {
      console.log(err);
      return;
    }

    console.log(resp);
  })

})

and I still get error

{ Error: Domain not found.
    at Request._callback (/home/kunok/code/sampleApi/node_modules/google-auth-library/lib/transporters.js:85:15)
    at Request.self.callback (/home/kunok/code/sampleApi/node_modules/google-auth-library/node_modules/request/request.js:198:22)
    at emitTwo (events.js:106:13)
    at Request.emit (events.js:191:7)
    at Request.<anonymous> (/home/kunok/code/sampleApi/node_modules/google-auth-library/node_modules/request/request.js:1057:14)
    at emitOne (events.js:101:20)
    at Request.emit (events.js:188:7)
    at IncomingMessage.<anonymous> (/home/kunok/code/sampleApi/node_modules/google-auth-library/node_modules/request/request.js:1003:12)
    at emitNone (events.js:91:20)
    at IncomingMessage.emit (events.js:185:7)
  code: 404,
  errors: 
   [ { domain: 'global',
       reason: 'notFound',
       message: 'Domain not found.' } ] }
0reactions
aheldcommented, Jan 7, 2019

The ‘domain not found’ error can also happen if you do not select a user to impersonate for the service account call.

const {auth, admin} = require('google-auth-library');

async function main() {

  const subject = 'user@yourDomain.com'
  
  const client = await auth.getClient({
    scopes: ['https://www.googleapis.com/auth/admin.directory.group']
  })

  //impersonate the users for whom you want to see the groups, or something like admin@yourdomain.com

  client.subject = subject    // <-- DO THIS

  const url = `https://www.googleapis.com/admin/directory/v1/groups?userKey=${subject}` //&maxResults=10`
  const res = await client.request({ url })
  console.log(res.data);
}

main().catch(console.error)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Decode JWT runtime error troubleshooting | Apigee Edge
This error occurs if the JSON Web Token (JWT) specified in the <Source> element of the Decode JWT policy is malformed, invalid or...
Read more >
Decode JWT runtime error troubleshooting | Apigee X
This error occurs if the JSON Web Token (JWT) specified in the <Source> element of the Decode JWT policy is malformed, invalid or...
Read more >
JWT (JSON Web Tokens) Errors | Invalid JWT Signature
This post reviews JWT errors and specifically how to resolve the invalid_grant:Invalid JWT Signature error. For Invalid JWT Signature, check if ...
Read more >
JWT Errors | Documentation - Web3Auth
JWT Errors · Invalid JWT Verifiers ID field.​ · Failed to verify JWS signature.​ · Duplicate token​ · Expired token​ · Mismatch JWT...
Read more >
Key Based Authentication Failed with "JWT token is invalid ...
This article explains what factors might cause key based authentication to fail with error "JWT token is invalid" and how to avoid it....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found