mirror of
https://github.com/samsonjs/instapaper.git
synced 2026-03-25 08:55:49 +00:00
configure params should be called oauth_token/secret
This commit is contained in:
parent
55af622159
commit
f745e5bc73
13 changed files with 26 additions and 26 deletions
|
|
@ -12,7 +12,7 @@ Instapaper is a ruby wrapper for interacting with [Instapaper's Full API](https:
|
|||
|
||||
## 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
|
||||
|
||||
|
|
@ -34,8 +34,8 @@ Also new in `1.x`
|
|||
client = Instapaper::Client.new do |client|
|
||||
client.consumer_key = YOUR_CONSUMER_KEY
|
||||
client.consumer_secret = YOUR_CONSUMER_SECRET
|
||||
client.access_token = YOUR_OAUTH_TOKEN
|
||||
client.access_token_secret = YOUR_OAUTH_TOKEN_SECRET
|
||||
client.oauth_token = YOUR_OAUTH_TOKEN
|
||||
client.oauth_token_secret = YOUR_OAUTH_TOKEN_SECRET
|
||||
end
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ module Instapaper
|
|||
# Defines methods related to OAuth
|
||||
module OAuth
|
||||
# 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')
|
||||
QLineParser.parse(response)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ module Instapaper
|
|||
include Instapaper::API
|
||||
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
|
||||
|
||||
# Initializes a new Client object
|
||||
|
|
@ -34,8 +34,8 @@ module Instapaper
|
|||
{
|
||||
consumer_key: @consumer_key,
|
||||
consumer_secret: @consumer_secret,
|
||||
access_token: @access_token,
|
||||
access_token_secret: @access_token_secret,
|
||||
oauth_token: @oauth_token,
|
||||
oauth_token_secret: @oauth_token_secret,
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,6 @@ module Instapaper
|
|||
attribute :title, String
|
||||
attribute :sync_to_mobile, String
|
||||
attribute :position, String
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ module Instapaper
|
|||
attribute :bookmark_id, String
|
||||
attribute :text, String
|
||||
attribute :position, String
|
||||
attribute :time, String
|
||||
end
|
||||
attribute :time, String
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -33,8 +33,8 @@ module Instapaper
|
|||
{
|
||||
consumer_key: @client.consumer_key,
|
||||
consumer_secret: @client.consumer_secret,
|
||||
token: @client.access_token,
|
||||
token_secret: @client.access_token_secret,
|
||||
token: @client.oauth_token,
|
||||
token_secret: @client.oauth_token_secret,
|
||||
}
|
||||
else
|
||||
@client.consumer_credentials
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@ module Instapaper
|
|||
include Virtus.value_object
|
||||
|
||||
values do
|
||||
attribute :type, String
|
||||
attribute :user_id, String
|
||||
attribute :username, String
|
||||
attribute :subscription_is_active, String
|
||||
end
|
||||
attribute :type, String
|
||||
attribute :user_id, String
|
||||
attribute :username, String
|
||||
attribute :subscription_is_active, String
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
require 'spec_helper'
|
||||
|
||||
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
|
||||
before do
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
require 'spec_helper'
|
||||
|
||||
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
|
||||
before do
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
require 'spec_helper'
|
||||
|
||||
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
|
||||
before do
|
||||
|
|
|
|||
|
|
@ -12,20 +12,20 @@ describe Instapaper::Client::OAuth do
|
|||
end
|
||||
|
||||
it 'gets the correct resource' do
|
||||
client.token('ohai', 'p455w0rd')
|
||||
client.access_token('ohai', 'p455w0rd')
|
||||
expect(a_post('/api/1/oauth/access_token'))
|
||||
.to have_been_made
|
||||
end
|
||||
|
||||
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.key?('oauth_token')).to be true
|
||||
expect(tokens.key?('oauth_token_secret')).to be true
|
||||
end
|
||||
|
||||
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.key?('error')).to be true
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
require 'spec_helper'
|
||||
|
||||
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
|
||||
it 'returns the credentials as hash' do
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ require 'spec_helper'
|
|||
|
||||
describe Instapaper::Error 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
|
||||
|
||||
describe '#code' do
|
||||
|
|
@ -26,7 +26,7 @@ describe Instapaper::Error do
|
|||
.to_return(status: status, body: '', headers: {content_type: 'application/json; charset=utf-8'})
|
||||
end
|
||||
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
|
||||
|
|
|
|||
Loading…
Reference in a new issue