-
-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Description
class XService
def initialize(access_token:, access_token_secret:)
x_credentials = {
api_key: Rails.application.credentials.dig(:x, :api_key),
api_key_secret: Rails.application.credentials.dig(:x, :secret_key),
access_token:,
access_token_secret:
}
@client = X::Client.new(**x_credentials)
@v1_client = X::Client.new(base_url: "https://api.twitter.com/1.1/", **x_credentials)
end
def verify_credentials
@v1_client.get("account/verify_credentials.json")
end
end
the api_key and the api_key_secret come from our developer dashboard, we are supplying the acquired access tokens but we get errors:
Bad Authentication data.
Keep in mind, we know these credentials are valid, I have a feeling this has to do with combining oauth acquired access tokens and our apps api keys/secrets?
Working example
BASE_URI = "https://api.twitter.com"
consumer = OAuth::Consumer.new(Rails.application.credentials.dig(:x, :api_key), Rails.application.credentials.dig(:x, :api_secret), site: BASE_URI)
@oauth_client = OAuth::AccessToken.new(consumer, access_token, access_token_secret)
@oauth_client.get("/1.1/account/verify_credentials.json")
Metadata
Metadata
Assignees
Labels
No labels