Hi, we’re using OAuth 1 and until recently we were able to make calls like this:
https://api.twitter.com/2/users/76821872?user.fields=public_metrics
But in the last few days we now get a 401 response on queries like this
{
"title": "Unauthorized",
"type": "about:blank",
"status": 401,
"detail": "Unauthorized"
}
Has anyone else seen this? Why would we be getting access denied trying to access public metrics? If I remove the parameter user.fields=public_metrics, then it works fine and returns:
{
"data": {
"id": "76821872",
"name": "Alex Black",
"username": "alexblackca"
}
}
1 Like
Are you getting unauthorized errors with other calls? Is the user you’re checking, 76821872, blocking the user whose access token you’re using? I can retrieve public_metrics using both app only and user auth.
Thanks for the response. That user id is my account, and I’m not blocking myself nor the other account I tested with.
This seems to happen for any user id. I haven’t tested with other endpoints.
1 Like
If it’s intermittent, i’d check your system clock to make sure it’s in sync (it affects oauth 1) - that’s the only other explanation i can think of!
Does it work consistently with a bearer token?
Thanks for the suggestions. Its not intermittent, and our service makes thousands of requests all the time to many other OAuth services without issue.
Ok I tried it with a bearer token, and it works as expected, it doesn’t return 401. That seems strange?
1 Like
It also works as expected in the Twitter API Oauth playground with our app.
1 Like
I’m gonna try switching to OAuth2, I imagine that will fix it, but not sure why…
1 Like
If oauth1 always fails - maybe the access token was revoked?, try resetting the access token entirely maybe? or maybe the library you’re using has a bug? no idea what it could be apart from that.
1 Like
We retested with oauth1 (same credentials and code) on another IP and it works there. It seems like a temporary ban from Twitter.
2 Likes