I'm trying to run starter locally and I get 401 unauthorized "invalid api key"

@AhsaUllah could you share why?

Could you share which started kit you are trying and also you have pasted your api key in env files?

The marketplace starter, Butterfly. Yes I have and it shows my api key inside the Authorization header so I know it’s working.

In the env folder, you need to set 3 variables,

  1. ENVIRONMENT = “production / sandbox”
  2. API_KEY = “Your API key”
  3. SITE_URL =“your domain name”

Note: If you have a production API key then need to pass in 1st variable “production” value or if you have a sandbox API key need to pass the "sandbox " value.
3rd variable is optional.

1 Like

Thanks. When I toggle between production and sandbox, I seem to get the same API key. am i missing something?

It shouldn’t show the same API key. We are checking why this is happening for you.

We have checked, there seems to be some cookie issue on our recent update, so it’s not refreshing.

Can you use production key for now?

In 2-3hours, we are providing a minor changes that will fix this issues.

I’m unable to switch the sdk from calling api.dev to production api url. This must be using the NODE_ENV variable to choose. When I set the NODE_ENV inside the package.json “dev” command it is throwing me an error. So I’m not able to use the production api key.

Would be better if sdk takes a config param to set the environment.

You don’t need to touch inside the packege.json file.
Change API_KEY and ENVIRONMENT variables from env file.
When you change anything in the env folder you need to close your terminal and rerun the project.

@ccc the sandbox issue is fixed. You may able to find the sandbox api key as well.


Still not working with sandbox key. :frowning:

Make sure, you changed your "environment " variable like this.
Note: don’t need anything to change in the packege.json file .

Hi @ccc if this still doesn’t works for you, let’s arrange a call for you, so we can troubleshoot together and understand why it doesn’t work for you