Hyper
Hyper

Reputation: 61

Access Twitter API after Firebase Authentication

After a successful twitter login through Firebase authentication, I am able to get user's oauthtoken and oauthsecret. Now I want to access twitter API through these credentials to fetch user's timeline, etc. But I can't find any way to do so. Making request to twitter API just returns "unauthorized" error.

This code:

await fetch('https://api.twitter.com/2/users/${user_id}/tweets', {
    headers: { Authorization: `Bearer ${token}` }, // Access token from Firebase
}

Will return this error:

data: {
    title: 'Unauthorized',
    type: 'about:blank',
    status: 401,
    detail: 'Unauthorized'
}

Upvotes: 0

Views: 49

Answers (1)

FaBotch
FaBotch

Reputation: 300

Twitter login through Firebase authentication does not allow you to use Twitter API.

You have implemented a login on Firebase with a twitter user account credentials. These credentials generated are for Firebase usage, not Twitter.

To use Twitter API you can follow the steps on the doc

Upvotes: 0

Related Questions