Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError null is not an object google-auth-library #11160

Closed
philosofonusus opened this issue May 18, 2024 · 3 comments
Closed

TypeError null is not an object google-auth-library #11160

philosofonusus opened this issue May 18, 2024 · 3 comments
Labels
bug Something isn't working needs repro Needs an example to reproduce

Comments

@philosofonusus
Copy link

philosofonusus commented May 18, 2024

What version of Bun is running?

1.1.8+89d25807f

What platform is your computer?

(Darwin 23.4.0 arm64 arm), (Linux x86_64)

What steps can reproduce the bug?

  1. bun init -y
  2. bun i google-auth-library@9.10.0
  3. add to index.ts this:
import { GoogleAuth } from "google-auth-library";

const serviceGoogleAccountAuth = new GoogleAuth({
  credentials: {
    client_email: process.env.GOOGLE_SERVICE_ACCOUNT_EMAIL as string,
    private_key: process.env.GOOGLE_SERVICE_ACCOUNT_PRIVATE_KEY as string,
  },
  scopes: ["https://www.googleapis.com/auth/spreadsheets"],
});
  1. create .env file with following fields filled in
    :
GOOGLE_SERVICE_ACCOUNT_EMAIL=
GOOGLE_SERVICE_ACCOUNT_PRIVATE_KEY=
  1. bun run index.ts

What is the expected behavior?

run program without error

What do you see instead?

CleanShot 2024-05-18 at 08 37 51@2x

Additional information

No response

@philosofonusus philosofonusus added the bug Something isn't working label May 18, 2024
@Electroid Electroid added the needs repro Needs an example to reproduce label May 20, 2024
@sirenkovladd
Copy link
Contributor

image

Using this document https://cloud.google.com/iam/docs/keys-create-delete#creating to get access keys
everything works fine for me

@philosofonusus
Copy link
Author

I have solved it, the issue consisted in env variables file, the following format of variables value didn't work:
GOOGLE_SERVICE_ACCOUNT_PRIVATE_KEY=-----BEGIN PRIVATE KEY----- ... -----END PRIVATE KEY-----
if you add double quotes around the value of this variable in such way:
GOOGLE_SERVICE_ACCOUNT_PRIVATE_KEY="-----BEGIN PRIVATE KEY----- ... -----END PRIVATE KEY-----"
it does work

@sirenkovladd
Copy link
Contributor

I think that this problem is solved and it can be closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs repro Needs an example to reproduce
Projects
None yet
Development

No branches or pull requests

3 participants