The request I am interested in is as follows: https://api.twitter.com/2/users/1402755743540039684
But I have also tried others, they all have the same result.

On postman it works correctly, while on react (javascript) it does not.
I don’t understand why. Please someone can help me

On react i made it like this:

        const headers = {
            'Accept': 'application/json',
            'Content-Type': 'application/json',
            'Authorization': 'Bearer ' + token
        }

        return fetch("https://api.twitter.com/2/users/1402755743540039684", {
            headers
        })
            .then(this._checkStatus)
            .then(response => {
                console.log(response);
                return response.json()
            })
            .catch((res) => {
                console.log(res);
            });
1 Like

Welcome to the community
So what error message is returned from your request response?

1 Like

TypeError: Failed to fetch

Too little error information, sorry but this is not enough to figure out the problem

I read that CORS requests are not enabled for Twitter web api, do you know if this could be the source of my problem?

not sure, are the credentials correct?

yes I used the same ones I used with postman ie Bearer token.
do you use api v2 too? does it work for you?

Yeah work for me

try to give me the whole error code returned

Error:

TypeError: Failed to fetch
    at Service.fetch (http://localhost:3000/static/js/bundle.js:2213:12)
    at TweetService.getTweets (http://localhost:3000/static/js/bundle.js:2328:29)
    at http://localhost:3000/static/js/bundle.js:457:18
    at invokePassiveEffectCreate (http://localhost:3000/static/js/bundle.js:91578:24)
    at HTMLUnknownElement.callCallback (http://localhost:3000/static/js/bundle.js:72194:18)
    at Object.invokeGuardedCallbackDev (http://localhost:3000/static/js/bundle.js:72243:20)
    at invokeGuardedCallback (http://localhost:3000/static/js/bundle.js:72303:35)
    at flushPassiveEffectsImpl (http://localhost:3000/static/js/bundle.js:91660:13)
    at unstable_runWithPriority (http://localhost:3000/static/js/bundle.js:104349:16)
    at runWithPriority$1 (http://localhost:3000/static/js/bundle.js:79600:14) {stack: 'TypeError: Failed to fetch
    at Service…/localhost:3000/static/js/bundle.js:79600:14)', message: 'Failed to fetch'}
1 Like

How did you make the request did you use fetch() or something else?
Are you using React?
Are you using Bearer Token?

Did you enable anything here?

Yeah You have to activate it, depending on which method you use, OAuth1.0 or 2.0
You can enable OAuth2.0 to use bearer app-only

What should I enter here? I would like to test locally first, but localhost didn’t work.

For testing you can use a tunnel like ngrok instead of localhost.
Another quite simple alternative you can use pipedream workflow, create workflow with http trigger, and you will get url

I have correctly implemented OAuth2.0 through firebase (permissions work correctly).

But what I needed not: that is to request through api the list of my posts, as explained here GET /2/users/:id/tweets | Docs | Twitter Developer Platform
using Bearer Token.

For the moment I solved it because I’m using nocodeapi.com as intermediary.

This I think is a problem of limitations or unintuitive settings that twitter should solve

Also now I have another problem with uploading images. In addition to twitter I’m also using developondo on other social and I haven’t had all these problems…

maybe this is the same case regarding firebase

no, I’m sorry.
I implemented OAuth2 under your advice, but it’s not my goal.
It’s not clear to me what OAuth2 is useful for, because I think it’s only for login and signup services.
I’m only interested in making api requests on my account information, so I’m not interested in generating a token through login