Class: OAuth::AccessToken

### Home Classes Methods

### In Files

- lib/oauth/tokens/access_token.rb

### Parent

ConsumerToken

### Methods

- #delete
- #get
- #head
- #post
- #put
- #request

### Files

- LICENSE
- README.rdoc
- TODO

### Class/Module Index

Quicksearch

- OAuth
- OAuth::AccessToken
- OAuth::CLI
- OAuth::Client
- OAuth::Client::Helper
- OAuth::Consumer
- OAuth::ConsumerToken
- OAuth::Error
- OAuth::Helper
- OAuth::OAuthTestHelper
- OAuth::Problem
- OAuth::RequestProxy
- OAuth::RequestProxy::ActionControllerRequest
- OAuth::RequestProxy::Base
- OAuth::RequestProxy::Curl
- OAuth::RequestProxy::Curl::Easy
- OAuth::RequestProxy::EventMachine
- OAuth::RequestProxy::EventMachine::HttpRequest
- OAuth::RequestProxy::JabberRequest
- OAuth::RequestProxy::MockRequest
- OAuth::RequestProxy::Net
- OAuth::RequestProxy::Net::HTTP
- OAuth::RequestProxy::Net::HTTP::HTTPRequest
- OAuth::RequestProxy::RackRequest
- OAuth::RequestProxy::Typhoeus
- OAuth::RequestProxy::Typhoeus::Request
- OAuth::RequestProxy::UnknownRequestType
- OAuth::RequestToken
- OAuth::Server
- OAuth::ServerToken
- OAuth::Signature
- OAuth::Signature::Base
- OAuth::Signature::HMAC
- OAuth::Signature::HMAC::Base
- OAuth::Signature::HMAC::MD5
- OAuth::Signature::HMAC::RMD160
- OAuth::Signature::HMAC::SHA1
- OAuth::Signature::HMAC::SHA2
- OAuth::Signature::MD5
- OAuth::Signature::PLAINTEXT
- OAuth::Signature::RSA
- OAuth::Signature::RSA::SHA1
- OAuth::Signature::SHA1
- OAuth::Signature::UnknownSignatureMethod
- OAuth::Token
- OAuth::Unauthorized
- ActionController
- ActionController::Base
- ActionController::TestRequest
- Digest
- Digest::HMAC
- EventMachine
- EventMachine::HttpClient
- Net
- Net::HTTPGenericRequest
- Object
- String

No matching classes.

# 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, line 67
    def delete(path, headers = {})
      request(:delete, path, headers)
    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, line 26
    def get(path, headers = {})
      request(:get, path, headers)
    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, line 34
    def head(path, headers = {})
      request(:head, path, headers)
    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, line 46
    def post(path, body = '', headers = {})
      request(:post, path, body, headers)
    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, line 58
    def put(path, body = '', headers = {})
      request(:put, path, body, headers)
    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.

    # File lib/oauth/tokens/access_token.rb, line 6
    def request(http_method, path, *arguments)
      request_uri = URI.parse(path)
      site_uri = consumer.uri
      is_service_uri_different = (request_uri.absolute? && request_uri != site_uri)
      begin
        consumer.uri(request_uri) if is_service_uri_different
        @response = super(http_method, path, *arguments)
      ensure
        # NOTE: reset for wholesomeness? meaning that we admit only AccessToken service calls may use different URIs?
        # so reset in case consumer is still used for other token-management tasks subsequently?
        consumer.uri(site_uri) if is_service_uri_different
      end
      @response
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.