DanielaSfregola / twitter4s

An asynchronous non-blocking Scala client for both the Twitter Rest and Streaming API
Apache License 2.0
256 stars 100 forks source link

Bad Authentication Data #354

Closed mnotti closed 3 years ago

mnotti commented 3 years ago

Just setting up twitter account for the first time and getting the following error when I try to make any API call:

encountered exception with timeline: com.danielasfregola.twitter4s.exceptions.TwitterException: [400 Bad Request] Bad Authentication data. (215)

I included some prints in my code to check the authorization data is correct (loaded from my reference.conf) and it matches what I see in my twitter dev account... is there some other env setup I have to do to make this work or is this an issue with the lib?

Here's my code:

import com.danielasfregola.twitter4s.TwitterRestClient

import scala.util.{Failure, Success}

object PotentQuotables extends App {
  import scala.concurrent.ExecutionContext.Implicits.global

  val restClient = TwitterRestClient()

  println(s"initializing session with")
  println(s"accessToken: ${restClient.accessToken}")
  println(s"consumerToken: ${restClient.consumerToken}")

  val f = restClient.homeTimeline()

  f onComplete{
    case Success(timeline) => println(s"got timeline! $timeline")
    case Failure(e) => println(s"encountered exception with timeline: $e")
  }
}
mnotti commented 3 years ago

very strange... I got it to work by revoking my Access Token (generated for read only) and generating a new one with read AND write permissions.

Odd, because the timeline request should just be a read. Anyway, happy it's working now!