Project

daum_oauth

0.0
No commit activity in last 3 years
No release in over 3 years
Daum OAuth API client library for ruby
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies
 Project Readme

Daum OAuth¶ ↑

About¶ ↑

This is Daum OAuth client API library for ruby.

Motivated by moomerman’s twitter_oauth gem (github.com/moomerman/twitter_oauth)

OAuth specs: oauth.net/core/1.0/

OAuth Introduction @ Daum DNA: apis.daum.net/oauth/

Installing¶ ↑

sudo gem install daum_oauth

Source code is available at github.com/thefron/daum_oauth

Usage¶ ↑

client = DaumOAuth::Client.new( :consumer_key => ‘YOUR_APP_CONSUMER_KEY’, :consumer_secret => ‘YOUR_APP_CONSUMER_SECRET’ ) request_token = client.request_token(:oauth_callback => ‘callback_url’) #:oauth_callback must be specified

request_token.authorize_url => apis.daum.net/oauth/authorize?oauth_token=TOKEN

In your application, make users redirect to the authorize_url(daum). Before redirection, store the request token and secret(usually in the session).Then users will authorize the application and be redirected to callback_url you’ve specified before.

Then in callback procedure,

access_token = client.authorize( request_token.token, request_token.secret, :oauth_verifier => params )

#For now, there’s no method for checking authorization’s validity. #At least, you can try this if your application makes use of yozm. client.yozm_authorized? => true

client.yozm_add ‘message here’ # sends a yozm message

Now if you can keep access_token(usually in the database) for this user, you won’t need re-authorize them next time. Just initialize a client instance with stored access_token when needed.

access_token = @user.access_token #assuming @user

client = DaumOAuth::Client.new( :consumer_key => ‘YOUR_APP_CONSUMER_KEY’, :consumer_secret => ‘YOUR_APP_CONSUMER_SECRET’, :token => access_token.token, :secret=> access_token.secret )

You are ready to access protected resource.