Forum Academy Marketplace Showcase Pricing Features

Twitter Search via API

Has anyone been able to use Twitter’s “Application-only” API to run a search of tweets from Bubble? The benefit of this API from Twitter is that is doesn’t require being logged into Twitter to call the Twitter API. See https://developer.twitter.com/en/docs/basics/authentication/oauth-2-0/application-only

It seems quite complicated. For starters, what type of authentication of the types available in Bubble should be used? Presumably one of the OAuth2’s?

you can remove the private to the q key

Can you kindly clarify a bit more what you mean?

Thank you!

No, none or self handled. It is an encoded Bearer token.

The in header you will put Authorization and Bearer : whateverererererere

The “whateverererererere” bit are the consumer key and secret messed about with …

  1. URL encode the consumer key and consumer secret according to RFC 1738. Note that at the time of writing, this will not actually change the consumer key and secret, but this step should still be performed in case the format of those values changes in the future.
  2. Concatenate the encoded consumer key, a colon character “:”, and the encoded consumer secret into a single string.
  3. Base64 encode the string from the previous step.

You don’t need to do this on Bubble, you can use online tools.

https://meyerweb.com/eric/tools/dencoder/
and

Thank you so much for taking the time write this. It has been very helpful!

It seems that there is an additional step. Here is my understanding:

  • First, a user must encode the consumer key and secret to obtain Bearer Token credentials. This requires a Key Value of Authorization and Basic in the header.

  • Second, use the encoded/Bearer Token credentials to obtain the actual Bearer Token. This requires a Key Value of Authorization and Bearer in the header.

My understanding is based on the following Twitter docs:

  1. POST oauth2/token

  2. Using and generating a Bearer Token

  3. Application-only authentication and OAuth 2.0 Bearer Token

Based on the above, I’m unsuccessfully trying to use Bubble to send a Post API call to obtain my Bearer token based on my Bearer Token credentials, as shown in the following image:

It is not working. I am getting the following error when I try to Initialize call in Bubble: “undefined error: this header name is not correct undefined”

Any additional assistance would be greatly appreciated!

You need to use a cutom oauth2 Authentication type and not a self handled.
https://api.twitter.com/oauth2/token?grant_type=client_credentials
And the authorization header into the Token Call header and not in shared header

I don’t know why but my previous message with the screenshot didn’t get uploader. I will try to send a new one later

That would be great - thank you very much!

3 Likes

Thanks, @Jici this did the trick! I really appreciate you taking the time to explain it to me!

I’m curious why Twitter’s docs say that Name is a required parameter when it clearly is not. See https://developer.twitter.com/en/docs/basics/authentication/api-reference/token

Also, can you recommend any resources to learn more about APIs for these types of situations? Thanks!

1 Like

This is just the title of column (Name of the parameter, if this is requiered or not, the description…)

Hello,

Thanks for your help. I am trying to post tweets from an account and it seems impossible for me. Where do you get the Value Code?

Thanks on advance

Alejandro, this is how I call Twitter in Bubble. I use it to search tweets

Do you have any more questions?

1 Like

Hello @hshadab. First of all, thanks a lot for your replying.

The thing is that I achieved to get to that screen you post but I cannot obtain just the hidden code that you draw in red colour. I made it for Airtable, but I cannot obtain for Twitter in this website:

https://developer.twitter.com/en/docs/authentication/oauth-2-0/application-only

Sorry if these question are a bit simple, but I am still a beginner

Thanks

This should help Twitter Search via API

1 Like