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

[BUG]: Neither apiKey nor config.authenticator provided #667

Open
yafkari opened this issue Oct 13, 2024 · 13 comments
Open

[BUG]: Neither apiKey nor config.authenticator provided #667

yafkari opened this issue Oct 13, 2024 · 13 comments
Labels
bug Something isn't working

Comments

@yafkari
Copy link

yafkari commented Oct 13, 2024

What happened?

Upgrading to 4.8.0 makes calling loadStripe to crash giving the error "Neither apiKey nor config.authenticator provided"

Please have a look at stripe/stripe-node#2207

Environment

No response

Reproduction

No response

@yafkari yafkari added the bug Something isn't working label Oct 13, 2024
@berenar
Copy link

berenar commented Oct 14, 2024

Same here

@Brakkar
Copy link

Brakkar commented Oct 14, 2024

Same here with node stripe 17.2.0 , on a firebase cloud function code. I'm NOT using NextJs at all.

@bclayton21
Copy link

Same here, I'm also experiencing this while using firebase cloud functions.

@WissemF123
Copy link

Do you find the solution ? Because I have the same error

@brendanm-stripe
Copy link
Contributor

Doe anyone have an example/reproduction they can share?

@bclayton21 can you say more about how this work? I don't understand how you'd be loading/using Stripe.js in this context.

@Brakkar
Copy link

Brakkar commented Oct 16, 2024

See if this solution helps:
https://stackoverflow.com/questions/79086035/firebase-deploy-error-neither-apikey-nor-config-authenticator-provided-using-s/

@brendanm-stripe
Copy link
Contributor

Are any of you having this issue with this package specifically? @stripe/stripe-js and NOT stripe-node aka stripe NPM package?

@yafkari you mentioned loadStripe which would be from this library. Can you share more about how you're using loadStripe? Are you also providing the PK via an environment variable? This all sounds like something has change with the way environment variables are loaded/initialized, so I would suggest trying first with a hard-coded key, then check your env var key is populated like you expect. If its not, you'll need to investigate why that is.

@yafkari
Copy link
Author

yafkari commented Oct 16, 2024

Hey @brendanm-stripe , thanks for looking into this.

Indeed, I pass env variables to loadStripe. I've put screenshots on my comment here: stripe/stripe-node#2207 (comment)

Should have copied them in the issue, my bad.

@brendanm-stripe
Copy link
Contributor

At the time you call loadStripe are you sure the environment variable has the value you expect? Do you have the same problem if you put your PK in as a string constant?

@abyssbandit97
Copy link

function createStripeInstance() {
const stripe = require('stripe')(process.env.STRIPE_SECRET);
return stripe;
}
module.exports = createStripeInstance;

i put this code in a utils/stripe.js file and i get this error: Uncaught Error Error: Neither apiKey nor config.authenticator provided

If I don't use it, I get undefined

@brendanm-stripe
Copy link
Contributor

What is your environment @abyssbandit97 ? Does providing the key as a string constant (not an environment variable) resolve the error?

@WissemF123
Copy link

@brendanm-stripe that is my file :
import Stripe from "stripe";

export const stripe = new Stripe(process.env.STRIPE_SECRET_KEY ?? "", {
apiVersion: "2024-09-30.acacia",
typescript: true,
});
And I get the same error

@maiconsanson
Copy link

maiconsanson commented Oct 19, 2024

I had the same problem (production only) after the following package updates:

from "stripe": "16.12.0" to "stripe": "17.2.1"
from "@stripe/stripe-js": "4.7.0" to "@stripe/stripe-js": "4.8.0"

After a rollback, the error disappears.

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

No branches or pull requests

8 participants