Created
April 21, 2011 08:15
-
-
Save nov/933962 to your computer and use it in GitHub Desktop.
MAC and Bearer Sample for OAuth.jp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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