Skip to content

Instantly share code, notes, and snippets.

@nov
Created April 21, 2011 08:15
Show Gist options
  • Save nov/933962 to your computer and use it in GitHub Desktop.
Save nov/933962 to your computer and use it in GitHub Desktop.
MAC and Bearer Sample for OAuth.jp
require 'rack/oauth2'
bearer_token = Rack::OAuth2::AccessToken::Bearer.new(
:access_token => ACCESS_TOKEN
)
bearer_token.get RESOURCE_URI
bearer_token.post RESOURCE_URI, {:message => 'Hello World!'}
bearer_token.put RESOURCE_URI, {:message => 'Hello World!'}
bearer_token.delete RESOURCE_URI
mac_token = Rack::OAuth2::AccessToken::MAC.new(
:access_token => ACCESS_TOKEN,
:secret => ACCESS_TOKEN_SECRET,
:algorithm => 'hmac-sha-256' # or 'hmac-sha-1'
)
mac_token.get RESOURCE_URI
mac_token.post RESOURCE_URI, {:message => 'Hello World!'}
mac_token.put RESOURCE_URI, {:message => 'Hello World!'}
mac_token.delete RESOURCE_URI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment