class OAuth::AccessToken

The Access Token is used for the actual โ€œrealโ€ web service calls that you perform against the server

Public Instance Methods

delete(path, headers = {}) click to toggle source

Make a regular DELETE request using AccessToken

@response = @token.delete('/people/123')
@response = @token.delete('/people/123', { 'Accept' => 'application/xml' })
   # File lib/oauth/tokens/access_token.rb
81 def delete(path, headers = {})
82   request(:delete, path, headers)
83 end
get(path, headers = {}) click to toggle source

Make a regular GET request using AccessToken

@response = @token.get('/people')
@response = @token.get('/people', { 'Accept'=>'application/xml' })
   # File lib/oauth/tokens/access_token.rb
28 def get(path, headers = {})
29   request(:get, path, headers)
30 end
head(path, headers = {}) click to toggle source

Make a regular HEAD request using AccessToken

@response = @token.head('/people')
   # File lib/oauth/tokens/access_token.rb
36 def head(path, headers = {})
37   request(:head, path, headers)
38 end
patch(path, body = "", headers = {}) click to toggle source

Make a regular PATCH request using AccessToken

@response = @token.patch('/people/123')
@response = @token.patch('/people/123', { :name => 'Bob', :email => 'bob@mailinator.com' })
@response = @token.patch('/people/123', { :name => 'Bob', :email => 'bob@mailinator.com' }, { 'Accept' => 'application/xml' })
@response = @token.patch('/people/123', nil, { 'Accept' => 'application/xml' })
@response = @token.patch('/people/123', @person.to_xml, { 'Accept' => 'application/xml', 'Content-Type' => 'application/xml' })
   # File lib/oauth/tokens/access_token.rb
72 def patch(path, body = "", headers = {})
73   request(:patch, path, body, headers)
74 end
post(path, body = "", headers = {}) click to toggle source

Make a regular POST request using AccessToken

@response = @token.post('/people')
@response = @token.post('/people', { :name => 'Bob', :email => 'bob@mailinator.com' })
@response = @token.post('/people', { :name => 'Bob', :email => 'bob@mailinator.com' }, { 'Accept' => 'application/xml' })
@response = @token.post('/people', nil, {'Accept' => 'application/xml' })
@response = @token.post('/people', @person.to_xml, { 'Accept'=>'application/xml', 'Content-Type' => 'application/xml' })
   # File lib/oauth/tokens/access_token.rb
48 def post(path, body = "", headers = {})
49   request(:post, path, body, headers)
50 end
put(path, body = "", headers = {}) click to toggle source

Make a regular PUT request using AccessToken

@response = @token.put('/people/123')
@response = @token.put('/people/123', { :name => 'Bob', :email => 'bob@mailinator.com' })
@response = @token.put('/people/123', { :name => 'Bob', :email => 'bob@mailinator.com' }, { 'Accept' => 'application/xml' })
@response = @token.put('/people/123', nil, { 'Accept' => 'application/xml' })
@response = @token.put('/people/123', @person.to_xml, { 'Accept' => 'application/xml', 'Content-Type' => 'application/xml' })
   # File lib/oauth/tokens/access_token.rb
60 def put(path, body = "", headers = {})
61   request(:put, path, body, headers)
62 end
request(http_method, path, *arguments) click to toggle source

The less intrusive way. Otherwise, if we are to do it correctly inside consumer, we need to restructure and touch more methods: request(), sign!(), etc.

Calls superclass method
   # File lib/oauth/tokens/access_token.rb
 8 def request(http_method, path, *arguments)
 9   request_uri = URI.parse(path)
10   site_uri = consumer.uri
11   is_service_uri_different = request_uri.absolute? && request_uri != site_uri
12   begin
13     consumer.uri(request_uri) if is_service_uri_different
14     @response = super(http_method, path, *arguments)
15   ensure
16     # NOTE: reset for wholesomeness? meaning that we admit only AccessToken service calls may use different URIs?
17     # so reset in case consumer is still used for other token-management tasks subsequently?
18     consumer.uri(site_uri) if is_service_uri_different
19   end
20   @response
21 end