configure params should be called oauth_token/secret

This commit is contained in:
stve 2015-02-17 23:32:34 -05:00
parent 55af622159
commit f745e5bc73
13 changed files with 26 additions and 26 deletions

View file

@ -12,7 +12,7 @@ Instapaper is a ruby wrapper for interacting with [Instapaper's Full API](https:
## Usage ## Usage
This library offers full support for all methods exposed through Instapaper's Full API. Note that Instapaper's API does not support the request-token/authorize workflow. To obtain an access token, use the `token` method. This library offers full support for all methods exposed through Instapaper's Full API. Note that Instapaper's API does not support the request-token/authorize workflow. To obtain an access token, use the `access_token` method.
## Changes in 1.0.0 ## Changes in 1.0.0
@ -34,8 +34,8 @@ Also new in `1.x`
client = Instapaper::Client.new do |client| client = Instapaper::Client.new do |client|
client.consumer_key = YOUR_CONSUMER_KEY client.consumer_key = YOUR_CONSUMER_KEY
client.consumer_secret = YOUR_CONSUMER_SECRET client.consumer_secret = YOUR_CONSUMER_SECRET
client.access_token = YOUR_OAUTH_TOKEN client.oauth_token = YOUR_OAUTH_TOKEN
client.access_token_secret = YOUR_OAUTH_TOKEN_SECRET client.oauth_token_secret = YOUR_OAUTH_TOKEN_SECRET
end end
``` ```

View file

@ -5,7 +5,7 @@ module Instapaper
# Defines methods related to OAuth # Defines methods related to OAuth
module OAuth module OAuth
# Gets an OAuth access token for a user. # Gets an OAuth access token for a user.
def token(username, password) def access_token(username, password)
response = perform_post_with_unparsed_response('/api/1/oauth/access_token', x_auth_username: username, x_auth_password: password, x_auth_mode: 'client_auth') response = perform_post_with_unparsed_response('/api/1/oauth/access_token', x_auth_username: username, x_auth_password: password, x_auth_mode: 'client_auth')
QLineParser.parse(response) QLineParser.parse(response)
end end

View file

@ -8,7 +8,7 @@ module Instapaper
include Instapaper::API include Instapaper::API
include Instapaper::HTTP::Utils include Instapaper::HTTP::Utils
attr_accessor :access_token, :access_token_secret, :consumer_key, :consumer_secret, :proxy attr_accessor :oauth_token, :oauth_token_secret, :consumer_key, :consumer_secret, :proxy
attr_writer :user_agent attr_writer :user_agent
# Initializes a new Client object # Initializes a new Client object
@ -34,8 +34,8 @@ module Instapaper
{ {
consumer_key: @consumer_key, consumer_key: @consumer_key,
consumer_secret: @consumer_secret, consumer_secret: @consumer_secret,
access_token: @access_token, oauth_token: @oauth_token,
access_token_secret: @access_token_secret, oauth_token_secret: @oauth_token_secret,
} }
end end

View file

@ -10,6 +10,6 @@ module Instapaper
attribute :title, String attribute :title, String
attribute :sync_to_mobile, String attribute :sync_to_mobile, String
attribute :position, String attribute :position, String
end end
end end
end end

View file

@ -11,6 +11,6 @@ module Instapaper
attribute :text, String attribute :text, String
attribute :position, String attribute :position, String
attribute :time, String attribute :time, String
end end
end end
end end

View file

@ -33,8 +33,8 @@ module Instapaper
{ {
consumer_key: @client.consumer_key, consumer_key: @client.consumer_key,
consumer_secret: @client.consumer_secret, consumer_secret: @client.consumer_secret,
token: @client.access_token, token: @client.oauth_token,
token_secret: @client.access_token_secret, token_secret: @client.oauth_token_secret,
} }
else else
@client.consumer_credentials @client.consumer_credentials

View file

@ -5,10 +5,10 @@ module Instapaper
include Virtus.value_object include Virtus.value_object
values do values do
attribute :type, String attribute :type, String
attribute :user_id, String attribute :user_id, String
attribute :username, String attribute :username, String
attribute :subscription_is_active, String attribute :subscription_is_active, String
end end
end end
end end

View file

@ -1,7 +1,7 @@
require 'spec_helper' require 'spec_helper'
describe Instapaper::Client::Bookmarks do describe Instapaper::Client::Bookmarks do
let(:client) { Instapaper::Client.new(consumer_key: 'CK', consumer_secret: 'CS', access_token: 'OT', access_token_secret: 'OS') } let(:client) { Instapaper::Client.new(consumer_key: 'CK', consumer_secret: 'CS', oauth_token: 'OT', oauth_token_secret: 'OS') }
describe '#bookmarks' do describe '#bookmarks' do
before do before do

View file

@ -1,7 +1,7 @@
require 'spec_helper' require 'spec_helper'
describe Instapaper::Client::Folders do describe Instapaper::Client::Folders do
let(:client) { Instapaper::Client.new(consumer_key: 'CK', consumer_secret: 'CS', access_token: 'OT', access_token_secret: 'OS') } let(:client) { Instapaper::Client.new(consumer_key: 'CK', consumer_secret: 'CS', oauth_token: 'OT', oauth_token_secret: 'OS') }
describe '#folders' do describe '#folders' do
before do before do

View file

@ -1,7 +1,7 @@
require 'spec_helper' require 'spec_helper'
describe Instapaper::Client::Highlights do describe Instapaper::Client::Highlights do
let(:client) { Instapaper::Client.new(consumer_key: 'CK', consumer_secret: 'CS', access_token: 'OT', access_token_secret: 'OS') } let(:client) { Instapaper::Client.new(consumer_key: 'CK', consumer_secret: 'CS', oauth_token: 'OT', oauth_token_secret: 'OS') }
describe '#highlights' do describe '#highlights' do
before do before do

View file

@ -12,20 +12,20 @@ describe Instapaper::Client::OAuth do
end end
it 'gets the correct resource' do it 'gets the correct resource' do
client.token('ohai', 'p455w0rd') client.access_token('ohai', 'p455w0rd')
expect(a_post('/api/1/oauth/access_token')) expect(a_post('/api/1/oauth/access_token'))
.to have_been_made .to have_been_made
end end
it 'returns the a hash containing an oauth token and secret' do it 'returns the a hash containing an oauth token and secret' do
tokens = client.token('ohai', 'p455w0rd') tokens = client.access_token('ohai', 'p455w0rd')
expect(tokens).to be_a Hash expect(tokens).to be_a Hash
expect(tokens.key?('oauth_token')).to be true expect(tokens.key?('oauth_token')).to be true
expect(tokens.key?('oauth_token_secret')).to be true expect(tokens.key?('oauth_token_secret')).to be true
end end
it 'returns a hash containing the error on invalid credentials' do it 'returns a hash containing the error on invalid credentials' do
tokens = client.token('inval1d', 'cr3dentials') tokens = client.access_token('inval1d', 'cr3dentials')
expect(tokens).to be_a Hash expect(tokens).to be_a Hash
expect(tokens.key?('error')).to be true expect(tokens.key?('error')).to be true
end end

View file

@ -1,7 +1,7 @@
require 'spec_helper' require 'spec_helper'
describe Instapaper::Client do describe Instapaper::Client do
let(:client) { Instapaper::Client.new(consumer_key: 'CK', consumer_secret: 'CS', access_token: 'OT', access_token_secret: 'OS') } let(:client) { Instapaper::Client.new(consumer_key: 'CK', consumer_secret: 'CS', oauth_token: 'OT', oauth_token_secret: 'OS') }
describe '#credentials' do describe '#credentials' do
it 'returns the credentials as hash' do it 'returns the credentials as hash' do

View file

@ -2,7 +2,7 @@ require 'spec_helper'
describe Instapaper::Error do describe Instapaper::Error do
before do before do
@client = Instapaper::Client.new(consumer_key: 'CK', consumer_secret: 'CS', access_token: 'AT', access_token_secret: 'AS') @client = Instapaper::Client.new(consumer_key: 'CK', consumer_secret: 'CS', oauth_token: 'AT', oauth_token_secret: 'AS')
end end
describe '#code' do describe '#code' do
@ -26,7 +26,7 @@ describe Instapaper::Error do
.to_return(status: status, body: '', headers: {content_type: 'application/json; charset=utf-8'}) .to_return(status: status, body: '', headers: {content_type: 'application/json; charset=utf-8'})
end end
it "raises #{exception}" do it "raises #{exception}" do
expect { @client.token('foo', 'bar') }.to raise_error(Instapaper::Error) expect { @client.access_token('foo', 'bar') }.to raise_error(Instapaper::Error)
end end
end end
end end