0

having a problem that when I try to run my cloud function where my secret key is being perceived as invalid. I am 99.99% sure that it is the same as is in the Stripe dashboard and have copied and pasted 100 times so I think it is something else.

{success: false, error: Invalid API Key provided: sk_test_**********************************************************************************************************************************************************************************************************}

If anyone could help that would be fantastic.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • can you also provide the entire function with masking api key and other important stuff because with this little information we cannot determine what is the issue and which docs are you following? – Rohit Kharche Jan 06 '23 at 14:19

2 Answers2

0

Can you double check if there's any extra empty space characters being added to the API key that you specified in the cloud function? Or if you are reading the API key from a config file, try hardcode it directly to the code and see if it solves the problem.

qichuan
  • 1,110
  • 7
  • 8
0

Initial thoughts...

  1. Ensure you have setup a restricted key with the specified security.

  2. Could this be an issue with the secret manager, invalidating your key here and reconfiguring https://console.cloud.google.com/security/secret-manager?referrer=search&project={your-project-id} may fix the issue.

  3. If you install a new instance, do you still have the same issue?

  4. If you can run locally, does the key work ok in small nodejs project for example, depending on which extension you are using:

import Stripe from 'stripe';
// invoices extension: apiVersion: '2020-03-02',
// payments extension: apiVersion = '2020-08-27';
const stripe = new Stripe('sk_test_...', {
  apiVersion: '2022-11-15',
});

const createCustomer = async () => {
  const params: Stripe.CustomerCreateParams = {
    description: 'test customer',
  };

  const customer: Stripe.Customer = await stripe.customers.create(params);

  console.log(customer.id);
};
createCustomer();
Darren Ackers
  • 148
  • 1
  • 6