1

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/

Abimaran Kugathasan
  • 31,165
  • 11
  • 75
  • 105
  • Are you getting this error when trying to run this in a Docker container? If so, this is a duplicate of https://stackoverflow.com/questions/50134123/deploying-the-ballerina-integration-example-in-a-docker-container and the answer I've provided there should resolve this – Pubudu May 06 '18 at 07:29
  • I hope you pass the --config twitter.toml flag when you run the sample – Sameera Jayasoma May 06 '18 at 19:12

2 Answers2

2

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

1

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.

DSotnikov
  • 634
  • 3
  • 10