Ballerina: Twitter Connector : error: wso2.twitter:TwitterError, message: bad Authentication data

191 Views Asked by At

Getting following error when trying the twitter connector.

error: wso2.twitter:TwitterError, message: bad Authentication data.
at tweet.doTweet(MyTwitterService.bal:31)

Following is my code

doTweet(endpoint caller, http:Request request){
string message = check request.getTextPayload();
twitter:Status st = check twitter->tweet(message,"","");
http:Response response = new;
response.setTextPayload("ID "+ <string>st.id + " \n");
_=caller->respond(response);
}

What could be the issue?

Double checked about the credentials and they are correct.

Just following https://ballerina.io/learn/quick-tour/

2

There are 2 best solutions below

0
On

Shammi, I did follow the guidance[1]and was working fine. Anyway, please do enable trace logs from ballerina and verify the trace information. I guess it should due to credentials or bad token. You may use [2] to enable trace logs.

[1] Ballerina: Twitter Connector : error: wso2.twitter:TwitterError, message: bad Authentication data [2] https://ballerina.io/learn/by-example/http-trace-logs.html

0
On

This error can mean one of 3 things:

  1. You are not passing the toml file as config to the Ballerina run call. You need to create the twitter.toml (can obviously call it some other name) and pass it by doing:

ballerina run --config twitter.toml hello_service.bal

  1. The toml file does not have the right values. Go to http://apps.twitter.com, create an "application" there and generate the OAuth keys. Then copy and paste them into your twitter.toml.

  2. You OAuth keys are expired or you mixed them up while pasting into the toml file. Please double-check.