What's new? | Help | Directory | Sign in
Google
oauth-plugin
A Rails plugin for creating OAuth service providers and consumers
  
  
  
  
    
Search
for
Updated Nov 25, 2007 by pelleb
AccessToken  
How the AccessToken api works

Introduction

The AccessToken is used for accessing Web Services using the OAuth protocol.

See Spec

This is only used from the ConsumerService side.

AccessToken lifecycle

  1. ConsumerService Request an AccessToken from the ServiceProvider using an authorized RequestToken
  2. ConsumerService ServiceProvider's web service using the AccessToken's http request wrapper methods

Contains

Creation

You ask the RequestToken to exchange it self for an AccessToken from the ServiceProvider:

@access_token=@request_token.get_access_token

Accessing REST webservices

It wraps the ruby http/s object with simple methods for each http method:

# GET /people.xml
@response=@access_token.get('/people.xml')

# GET /people/1.xml
@response=@access_token.get('/people/1.xml')

# POST /people
@response=@access_token.post('/people',"person[name]=Bob")

# POST /people with xml
@response=@access_token.post('/people',@person.to_xml,{'Content-Type'=>'application/xml')

# PUT /people/1
@response=@access_token.post('/people/1',"person[name]=Bob%20Smith")

# PUT /people/1 with xml
@response=@access_token.put('/people/1',@person.to_xml,{'Content-Type'=>'application/xml')

# DELETE /people/1
@response=@access_token.delete('/people/1')

Comment by humbroll, Apr 01, 2008

there's some errata. {'Content-Type'=>'application/xml' => {'Content-Type'=>'application/xml'}

thanks for great document.


Sign in to add a comment