Skip to content

Commit

Permalink
Rename oauth_token to access_token
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed Aug 18, 2013
1 parent 239c5a8 commit d360f80
Show file tree
Hide file tree
Showing 20 changed files with 39 additions and 39 deletions.
4 changes: 2 additions & 2 deletions lib/twitter/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def initialize(attrs={})
#
# @param method [String, Symbol] Message to send to the object
def [](method)
send(method)
send(method.to_sym)
rescue NoMethodError
nil
end
Expand All @@ -133,7 +133,7 @@ def memoize(key, &block)
# @param other [Twitter::Base]
# @return [Boolean]
def attr_equal(attr, other)
self.class == other.class && !other.send(attr).nil? && send(attr) == other.send(attr)
self.class == other.class && !other.send(attr.to_sym).nil? && send(attr.to_sym) == other.send(attr.to_sym)
end

# @param other [Twitter::Base]
Expand Down
18 changes: 9 additions & 9 deletions lib/twitter/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ class Client
include Twitter::API::Users

attr_writer :bearer_token, :connection_options, :consumer_key,
:consumer_secret, :endpoint, :middleware, :oauth_token,
:oauth_token_secret
:consumer_secret, :endpoint, :middleware, :access_token,
:access_token_secret

ENDPOINT = 'https://api.twitter.com'

Expand All @@ -67,13 +67,13 @@ def consumer_secret
end

# @return [String]
def oauth_token
@oauth_token || ENV['TWITTER_oauth_token']
def access_token
@access_token || ENV['TWITTER_access_token']
end

# @return [String]
def oauth_token_secret
@oauth_token_secret || ENV['TWITTER_oauth_token_SECRET']
def access_token_secret
@access_token_secret || ENV['TWITTER_access_token_SECRET']
end

# @return [String]
Expand Down Expand Up @@ -150,7 +150,7 @@ def put(path, params={})

# @return [Boolean]
def user_token?
!!(oauth_token && oauth_token_secret)
!!(access_token && access_token_secret)
end

# @return [Boolean]
Expand All @@ -163,8 +163,8 @@ def credentials
{
:consumer_key => consumer_key,
:consumer_secret => consumer_secret,
:token => oauth_token,
:token_secret => oauth_token_secret,
:token => access_token,
:token_secret => access_token_secret,
}
end

Expand Down
2 changes: 1 addition & 1 deletion spec/twitter/api/direct_messages_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
describe Twitter::API::DirectMessages do

before do
@client = Twitter::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :oauth_token => "OT", :oauth_token_secret => "OS")
@client = Twitter::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :access_token => "AT", :access_token_secret => "AS")
end

describe "#direct_messages_received" do
Expand Down
2 changes: 1 addition & 1 deletion spec/twitter/api/favorites_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
describe Twitter::API::Favorites do

before do
@client = Twitter::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :oauth_token => "OT", :oauth_token_secret => "OS")
@client = Twitter::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :access_token => "AT", :access_token_secret => "AS")
end

describe "#favorites" do
Expand Down
2 changes: 1 addition & 1 deletion spec/twitter/api/friends_and_followers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
describe Twitter::API::FriendsAndFollowers do

before do
@client = Twitter::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :oauth_token => "OT", :oauth_token_secret => "OS")
@client = Twitter::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :access_token => "AT", :access_token_secret => "AS")
end

describe "#friend_ids" do
Expand Down
2 changes: 1 addition & 1 deletion spec/twitter/api/geo_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
describe Twitter::API::PlacesAndGeo do

before do
@client = Twitter::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :oauth_token => "OT", :oauth_token_secret => "OS")
@client = Twitter::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :access_token => "AT", :access_token_secret => "AS")
end

describe "#place" do
Expand Down
2 changes: 1 addition & 1 deletion spec/twitter/api/help_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
describe Twitter::API::Help do

before do
@client = Twitter::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :oauth_token => "OT", :oauth_token_secret => "OS")
@client = Twitter::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :access_token => "AT", :access_token_secret => "AS")
end

describe "#configuration" do
Expand Down
2 changes: 1 addition & 1 deletion spec/twitter/api/lists_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
describe Twitter::API::Lists do

before do
@client = Twitter::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :oauth_token => "OT", :oauth_token_secret => "OS")
@client = Twitter::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :access_token => "AT", :access_token_secret => "AS")
end

describe "#lists" do
Expand Down
2 changes: 1 addition & 1 deletion spec/twitter/api/saved_searches_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
describe Twitter::API::SavedSearches do

before do
@client = Twitter::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :oauth_token => "OT", :oauth_token_secret => "OS")
@client = Twitter::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :access_token => "AT", :access_token_secret => "AS")
end

describe "#saved_searches" do
Expand Down
2 changes: 1 addition & 1 deletion spec/twitter/api/search_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
describe Twitter::API::Search do

before do
@client = Twitter::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :oauth_token => "OT", :oauth_token_secret => "OS")
@client = Twitter::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :access_token => "AT", :access_token_secret => "AS")
end

describe "#search" do
Expand Down
2 changes: 1 addition & 1 deletion spec/twitter/api/spam_reporting_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
describe Twitter::API::SpamReporting do

before do
@client = Twitter::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :oauth_token => "OT", :oauth_token_secret => "OS")
@client = Twitter::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :access_token => "AT", :access_token_secret => "AS")
end

describe "#report_spam" do
Expand Down
2 changes: 1 addition & 1 deletion spec/twitter/api/suggested_users_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
describe Twitter::API::SuggestedUsers do

before do
@client = Twitter::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :oauth_token => "OT", :oauth_token_secret => "OS")
@client = Twitter::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :access_token => "AT", :access_token_secret => "AS")
end

describe "#suggestions" do
Expand Down
2 changes: 1 addition & 1 deletion spec/twitter/api/timelines_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
describe Twitter::API::Timelines do

before do
@client = Twitter::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :oauth_token => "OT", :oauth_token_secret => "OS")
@client = Twitter::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :access_token => "AT", :access_token_secret => "AS")
end

describe "#mentions_timeline" do
Expand Down
2 changes: 1 addition & 1 deletion spec/twitter/api/trends_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
describe Twitter::API::Trends do

before do
@client = Twitter::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :oauth_token => "OT", :oauth_token_secret => "OS")
@client = Twitter::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :access_token => "AT", :access_token_secret => "AS")
end

describe "#trends" do
Expand Down
2 changes: 1 addition & 1 deletion spec/twitter/api/tweets_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
describe Twitter::API::Tweets do

before do
@client = Twitter::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :oauth_token => "OT", :oauth_token_secret => "OS")
@client = Twitter::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :access_token => "AT", :access_token_secret => "AS")
end

describe "#retweets" do
Expand Down
2 changes: 1 addition & 1 deletion spec/twitter/api/undocumented_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
describe Twitter::API::Undocumented do

before do
@client = Twitter::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :oauth_token => "OT", :oauth_token_secret => "OS")
@client = Twitter::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :access_token => "AT", :access_token_secret => "AS")
end

describe "#following_followers_of" do
Expand Down
2 changes: 1 addition & 1 deletion spec/twitter/api/users_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
describe Twitter::API::Users do

before do
@client = Twitter::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :oauth_token => "OT", :oauth_token_secret => "OS")
@client = Twitter::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :access_token => "AT", :access_token_secret => "AS")
end

describe "#settings" do
Expand Down
22 changes: 11 additions & 11 deletions spec/twitter/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
describe Twitter::Client do

before do
@client = Twitter::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :oauth_token => "OT", :oauth_token_secret => "OS")
@client = Twitter::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :access_token => "AT", :access_token_secret => "AS")
end

describe ".new" do
Expand All @@ -30,20 +30,20 @@
expect(client.credentials?).to be_true
end
it "returns true if all OAuth credentials are present" do
client = Twitter::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :oauth_token => "OT", :oauth_token_secret => "OS")
client = Twitter::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :access_token => "AT", :access_token_secret => "AS")
expect(client.credentials?).to be_true
end
it "returns false if any credentials are missing" do
client = Twitter::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :oauth_token => "OT")
client = Twitter::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :access_token => "AT")
expect(client.credentials?).to be_false
end
end

it "does not cache the screen name across clients" do
stub_get("/1.1/account/verify_credentials.json").to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
user1 = Twitter::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :oauth_token => "OT", :oauth_token_secret => "OS").current_user
user1 = Twitter::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :access_token => "AT", :access_token_secret => "AS").current_user
stub_get("/1.1/account/verify_credentials.json").to_return(:body => fixture("pengwynn.json"), :headers => {:content_type => "application/json; charset=utf-8"})
user2 = Twitter::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :oauth_token => "OT", :oauth_token_secret => "OS").current_user
user2 = Twitter::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :access_token => "AT", :access_token_secret => "AS").current_user
expect(user1).not_to eq(user2)
end

Expand All @@ -69,11 +69,11 @@

describe "#user_token?" do
it "returns true if the user token/secret are present" do
client = Twitter::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :oauth_token => "OT", :oauth_token_secret => "OS")
client = Twitter::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :access_token => "AT", :access_token_secret => "AS")
expect(client.user_token?).to be_true
end
it "returns false if the user token/secret are not completely present" do
client = Twitter::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :oauth_token => "OT")
client = Twitter::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :access_token => "AT")
expect(client.user_token?).to be_false
end
end
Expand All @@ -91,11 +91,11 @@

describe "#credentials?" do
it "returns true if all credentials are present" do
client = Twitter::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :oauth_token => "OT", :oauth_token_secret => "OS")
client = Twitter::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :access_token => "AT", :access_token_secret => "AS")
expect(client.credentials?).to be_true
end
it "returns false if any credentials are missing" do
client = Twitter::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :oauth_token => "OT")
client = Twitter::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :access_token => "AT")
expect(client.credentials?).to be_false
end
end
Expand Down Expand Up @@ -139,8 +139,8 @@
expect(authorization.options[:version]).to eq("1.0")
expect(authorization.options[:consumer_key]).to eq("CK")
expect(authorization.options[:consumer_secret]).to eq("CS")
expect(authorization.options[:token]).to eq("OT")
expect(authorization.options[:token_secret]).to eq("OS")
expect(authorization.options[:token]).to eq("AT")
expect(authorization.options[:token_secret]).to eq("AS")
end
it "submits the correct auth header when no media is present" do
# We use static values for nounce and timestamp to get a stable signature
Expand Down
2 changes: 1 addition & 1 deletion spec/twitter/cursor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

describe "#each" do
before do
@client = Twitter::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :oauth_token => "OT", :oauth_token_secret => "OS")
@client = Twitter::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :access_token => "AT", :access_token_secret => "AS")
stub_get("/1.1/followers/ids.json").with(:query => {:cursor => "-1", :screen_name => "sferik"}).to_return(:body => fixture("ids_list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
stub_get("/1.1/followers/ids.json").with(:query => {:cursor => "1305102810874389703", :screen_name => "sferik"}).to_return(:body => fixture("ids_list2.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
Expand Down
2 changes: 1 addition & 1 deletion spec/twitter/error_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
describe Twitter::Error do

before do
@client = Twitter::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :oauth_token => "OT", :oauth_token_secret => "OS")
@client = Twitter::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :access_token => "AT", :access_token_secret => "AS")
end

describe "#initialize" do
Expand Down

0 comments on commit d360f80

Please sign in to comment.