#pritzstik

1 messages ยท Page 1 of 1 (latest)

queen gullBOT
sick heart
#

Hello

#

Threads get closed after a period of inactivity

#

If you will summarize your issue I'd be happy to help

brave shoal
#

Ah I see.

I was getting this error on a script I have for automating exporting reports. I have the api key in a .env file and it's reading it fine, because a CSV is getting generated, but it was coming up with this error:

{
"error": {
"message": "You did not provide an API key. You need to provide your API key in the Authorization header
"type": "invalid_request_error"
}
}

Your colleague stated that it's because "The error pretty much means that the API key wasn't correctly passed in when making a request to Stripe"

I wanted to know how do I fix that? If it's possible to fix at all?

sick heart
#

Hmm are you sure it isn't a different request that is throwing that error?

#

Have you tried hardcoding the key for a test and seeing if the same error happens?

brave shoal
#

Yep, tried hardcoding the key and it came back the same. Screenshot for context

#

I'm definitely using the secret key

sick heart
#

So you see that error but the request you are attempting does still work?

brave shoal
#

The request does work. I believe my script is sound. But I get this error every time.

#

Happy to share my code, nothing confidential in there

sick heart
#

It seems pretty clear to me then that there is somewhere else in your code that is attempting to make a request to our API but the key doesn't exist there

#

Have you added logs throughout your code to see when this error is actually thrown?

#

That would be the next step -- to see if you add logs throughout the path you are currently focused on and if all of those logs fire and then the error occurs

brave shoal
#

I haven't yet added logs. I can add logs now and see what happens.

sick heart
#

๐Ÿ‘

#

Let's try that and let me know what you see

brave shoal
#

Okay cool, give me 5 mins!

sick heart
#

Sure thing

brave shoal
#

This is what I see. Ignore the fact that I named the base directory = "dekstop"

sick heart
#

K I don't see any error there... ?

brave shoal
#

And yet when I ran it, the CSV came up with the same error message as before

#

The script is only attempting to make a request to the API once, it's nowhere else in the code

sick heart
#

So the error occurred after all of those logs?

brave shoal
#

Correct

sick heart
#

Can you take the specfiic script you are using and run it in a new isolated environment that is just solely that script?

brave shoal
#

I mean, I've been running it in separate venv away from other scripts, in separate folders.

sick heart
#

Yeah I'm not sure what else to suggest. Somewhere in your code there is an attempted request to the Stripe API and there is no key present...

#

I'm just trying to give you suggestions on how to debug but really you need to troubleshoot this from your side. We don't just throw that error for no reason. I understand nothing is jumping out but I can't help much further without having the project and being able to reproduce myself.

brave shoal
#

Yeah no I get that. I'm just as stumped as you are. I expected it to pass the API key normally, like my other scripts.

sick heart
#

Yep it is definitely strange

#

It is almost like something is causing a duplicative request and then your key gets dropped

#

But I really have no idea ๐Ÿ˜ฆ

#

If you try to make a different request than downloading the Report does the same thing happen?

queen gullBOT
brave shoal
#

Yeah I've tried that before coming here. No difference unfortunately

blissful jacinth
#

To clarify, have you isolated where you request will work and where it wouldn't?

brave shoal
#

Hahaha I think I know what the issue is. The issue is around the authentication method which needs to be changed to "Private Key in Header". At the moment it's set to "in URL" It's a problem on our side 100%.