How to set keys & access tokens for Twitter Spark streaming?

0 votes

I am executing a Spark Streaming example where I am fetching data from Twitter based on the specified tags. When I am running TwitterPopularTags.scala, I am getting authentication failure issue.

Later I figured out I am haven’t set the twitter login keys, which need to be provided.

System.setProperty("twitter4j.oauth.consumerKey", "****");
System.setProperty("twitter4j.oauth.consumerSecret", "****");
System.setProperty("twitter4j.oauth.accessToken", "****");
System.setProperty("twitter4j.oauth.accessTokenSecret", "****");
 

Can anyone explain me this how to do this?

May 24, 2018 in Apache Spark by coder_jazz
155 views

1 answer to this question.

0 votes

Either you have to create a Twitter4j.properties file where you need to specify the four keys or you can go ahead and specify the keys in you program as well. But you need to use twitter4j jar for that.

oauth.consumerKey=****
oauth.consumerSecret=****
oauth.accessToken=****
oauth.accessTokenSecret=****

Go to  https://apps.twitter.com/ link. There you need to create a Twitter application and you’ll get the keys in Keys & Access Tokens tab.

answered May 24, 2018 by Shubham
• 13,300 points

Related Questions In Apache Spark

0 votes
1 answer

How to set cpu cores for spark task?

By default, each task is allocated with ...READ MORE

answered Mar 12 in Apache Spark by Veer
360 views
0 votes
1 answer

How to give user only view access for Spark application?

You can give users only view permission ...READ MORE

answered Mar 14 in Apache Spark by Raj
28 views
0 votes
1 answer

How to set executors for static allocation in Spark Yarn?

Open Spark shell and run the following ...READ MORE

answered Mar 28 in Apache Spark by Raj
177 views
0 votes
1 answer

How to set extra JVM options for Spark application?

You cans set extra JVM options that ...READ MORE

answered Mar 28 in Apache Spark by Raj
406 views
0 votes
1 answer

Getting error while connecting zookeeper in Kafka - Spark Streaming integration

I guess you need provide this kafka.bootstrap.servers ...READ MORE

answered May 24, 2018 in Apache Spark by Shubham
• 13,300 points
631 views
0 votes
1 answer
0 votes
1 answer

Is it possible to run Apache Spark without Hadoop?

Though Spark and Hadoop were the frameworks designed ...READ MORE

answered May 2 in Big Data Hadoop by ravikiran
• 4,560 points
71 views
0 votes
1 answer

Hadoop Mapreduce word count Program

Firstly you need to understand the concept ...READ MORE

answered Mar 16, 2018 in Data Analytics by nitinrawat895
• 10,690 points
3,013 views
0 votes
3 answers

How to transpose Spark DataFrame?

Please check the below mentioned links for ...READ MORE

answered Dec 31, 2018 in Apache Spark by anonymous
6,013 views
0 votes
4 answers

How to change the spark Session configuration in Pyspark?

You can dynamically load properties. First create ...READ MORE

answered Dec 10, 2018 in Apache Spark by Vini
14,830 views