Using Api with a Service Account

  • 1
  • Problem
  • Updated 4 months ago
  • (Edited)
Hello.

I am writing a node service that will (among other things) wrap the rise vision api to serve via custom rest endpoints I am writing.

Once a user auths with my app through our own non-google auth service, I want to handle all risevision api calls on their behalf through the node service.

I currently have this node service using a service account to get a token, which then sets the credentials for the web app i have registered with risevision...


class GoogleAuthClient {

    constructor() {
        if (!instance) {
            this.oauth2Client = new OAuth2(clientId, clientSecret);

            const jwtClient = new google.auth.JWT(credentials.client_email, null, credentials.private_key, [config.google.scope], null);

            jwtClient.authorize((err, result) => {
                 if (err) {
                        console.log(err)
                 }
                 this.oauth2Client.setCredentials(result);

             })
        instance = this;
    }

    return instance;
}


Everything seems to work until i actually call a rest endpoint, at which point the response is:
"code": 401,
"message": "User is not authenticated"


The app (clientId) is registered and I have also created a user on the risevision dashboard with the same email as credentials.client_email.

Can anyone help me figure out what I am missing?
Photo of Anthony Sist

Anthony Sist

  • 70 Points

Posted 4 months ago

  • 1

There are no replies.