twittertwitter-oauth

Twitter API 401 when refreshing Token


I'm using twitter API to let users login with offline scope and trying to refresh their tokens when expired to keep access to their oauth.

But sometimes twitter API randomly throws below error:

TwitterResponseError: ... {
  status: 401,
  statusText: 'Unauthorized',
  headers: {
    'cache-control': 'no-cache, no-store, max-age=0',
    connection: 'close',
    'content-length': '99',
    'content-type': 'application/problem+json',
    date: 'Sat, 01 Apr 2023 23:22:04 GMT',
    perf: '7626143928',
    server: 'tsa_b',
    'x-connection-hash': '868ff5ec7376e3814861c6dcaebd3c6daa32496a175a41aceb426bda0f7b54b8',
    'x-response-time': '4',
    'x-transaction-id': 'b7c7ef409b154dde'
  },
  error: {
    title: 'Unauthorized',
    type: 'about:blank',
    status: 401,
    detail: 'Unauthorized'
  }

I've looked around but couldn't find any solution for that. And I know for certain that users haven't revoked their OAuth.

Any help would be highly appreciated.

I don't know if this is coincidental, but this error started occurring on 24th of March.


Solution

  • Fixed by trying another set of credentials