sferik / twitter-ruby

A Ruby interface to the Twitter API.
http://www.rubydoc.info/gems/twitter
MIT License
4.59k stars 1.31k forks source link

Oauth2 access token secret for Twitter #1022

Closed dorianmariecom closed 11 months ago

dorianmariecom commented 1 year ago

Hi,

I'm writing a Twitter client.

I have the access_token and refresh_token but I don't have the access_token_secret.

{"scope"=>"tweet.read offline.access", "expires_in"=>7200, "token_type"=>"bearer", "access_token"=>"a...E", "refresh_token"=>"NW...E", "raw_attributes"=>{"scope"=>"tweet.read offline.access", "expires_in"=>7200, "token_type"=>"bearer", "access_token"=>"aD...E", "refresh_token"=>"NW...E"}}

I would like to access the user's home timeline, how can I do that?

Here is the code for the client if it's relevant:

      @client ||= TwitterOAuth2::Client.new(
        identifier: credentials.client_id,
        secret: credentials.client_secret,
        redirect_uri: redirect_uri
      )

      uri = client.authorization_uri(scope: scope.split)
      update!(extras: {code_verifier: client.code_verifier})
      uri

      client.authorization_code = code
      update!(extras: client.access_token!(extras["code_verifier"]))