Error 403 in member profile

Sort:
fgawkfiv

Hello!

I have been using this endpoint: https://api.chess.com/pub/player/{user} to get info of a user. The endpoint works well in the navigator, but fails with Error 403 in my python code. What is wrong? Is this related with the OAuth 2.0 topic?

stephen_33

Did you see my comment in Notes? I might s well copy it here....

Anyone suddenly getting 403 (Access forbidden) response codes when trying to access endpoints they've used many times before? I can download the club/matches for my HQ club in a browser window: https://api.chess.com/pub/club/knockout-hq/matches ..but I can't call the endpoint as I normally do using the Python Requests function. Has something changed?

stephen_33

Looks as if something's broken? I don't think it has anything to do with 'OAuth 2.0' because you'd expect all access to be barred, not just programmatic access - I think you can still open the same endpoints in a browser window?

Wallace_Wang

Have you set "User-Agent" in your http header to your email address? I got the 403 too, put my email address there and it worked. They requested users to do this a while ago, perhaps they're enforcing it now.

stephen_33

Well this is the one I've been using for several years now ....

{'User-Agent': 'Chess.py (Python 3.7) (username: stephen_33; contact: swilliamsx33@gmail.com)'}

It's been fine in that format so far but has something changed?

* Do you mean reformat it like this? ...

{'User-Agent': 'swilliamsx33@gmail.com'}

Wallace_Wang
stephen_33 wrote:

Well this is the one I've been using for several years now ....

{'User-Agent': 'Chess.py (Python 3.7) (username: stephen_33; contact: swilliamsx33@gmail.com)'}

It's been fine in that format so far but has something changed?

* Do you mean reformat it like this? ...

{'User-Agent': 'swilliamsx33@gmail.com'}

I tried your format, replacing your info with mine, it worked. So I guess as long as there's an email address in User-Agent it should be fine.

stephen_33

No, that's just as bad.

@Wallace_Wang, would you mind posting the User-Agent you are using please so we can compare?

stephen_33
Wallace_Wang wrote:

I tried your format, replacing your info with mine, it worked. So I guess as long as there's an email address in User-Agent it should be fine.

But I'm still getting 403 (Access forbidden) response codes by the dozen while you're able to access endpoints normally, yes?

stephen_33

Bedtime for me.....

Wallace_Wang

For me it's just {'User-Agent': 'wallace.dev@proton.me'}. But {'User-Agent': 'username: wallace_wang, email: wallace.dev@proton.me'} also works for me.

scarpentus

Thank you! That works for me.

Martin_Stahl
stephen_33 wrote:
Wallace_Wang wrote:

I tried your format, replacing your info with mine, it worked. So I guess as long as there's an email address in User-Agent it should be fine.

But I'm still getting 403 (Access forbidden) response codes by the dozen while you're able to access endpoints normally, yes?

Are you running your code from the same IP space as you do when doing it via browser?

AfraidToShootStrangers

Hi, i'm a new chess player and an amateur programmer. I have wrote a very simple script in python to request stats info on my account and game history.

Since yesterday i'm getting error 403, same as you guys. I only run sequential requests as demanded in the policy.

Can you explain better to me the user-agent thing. It is a parameters?

Should i use in my request to chess.com api the parameter user-aget?

Is this something like that correct?

[CODE]

r = requests.get("https://api.chess.com/pub/player/playername/stats",

params = {'User-Agent': 'mycontact@gmail.com'})

[/CODE]

Thank you.

AfraidToShootStrangers

Wait what... I just noticed my request works if i write a script in R (i mean the statistical computing language from cran project).

It seems the 403 error only happens in my python script.

stephen_33
Martin_Stahl wrote:
stephen_33 wrote:

But I'm still getting 403 (Access forbidden) response codes by the dozen while you're able to access endpoints normally, yes?

Are you running your code from the same IP space as you do when doing it via browser?

Yes, I carry out all my activities from the same laptop and I was trying to run a routine (in Python) that calls various club-matches endpoints and getting nothing but 403 errors, then seeing if I could open them in a browser (Chrome) window and that worked as normal.

Something was changed around a day ago, do you know what that was?

Tricky_Dicky

Martin, why did you ask about IP address. Are these now being checked. API is open data why is IP an issue?

stephen_33

@Martin_Stahl, I'm sensing from some of the comments that this might be a Python specific problem - is that possible?

At least @Wallace_Wang isn't having any problem using the same User-Agent format and @AfraidToShootStrangers is fine in R....

"It seems the 403 error only happens in my python script"

stephen_33
Wallace_Wang wrote:

For me it's just {'User-Agent': 'wallace.dev@proton.me'}. But {'User-Agent': 'username: wallace_wang, email: wallace.dev@proton.me'} also works for me.

But what language are you working in, Python? If not, is it possible for you to make an endpoint call in Python?

Tricky_Dicky

Just run a couple of updates using Office 365 VBA without issue. Seems to be working OK.

Wallace_Wang
stephen_33 wrote:
Wallace_Wang wrote:

For me it's just {'User-Agent': 'wallace.dev@proton.me'}. But {'User-Agent': 'username: wallace_wang, email: wallace.dev@proton.me'} also works for me.

But what language are you working in, Python? If not, is it possible for you to make an endpoint call in Python?

I'm using Python.