Created
November 24, 2010 02:57
-
-
Save gamesthatgive/713018 to your computer and use it in GitHub Desktop.
Revisions
-
gamesthatgive revised this gist
Nov 24, 2010 . 1 changed file with 6 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,8 @@ # in routes.rb match '/oauth/create' => 'oauth#create', :as => 'oauth_callback' resource :oauth, :only => :new, :controller => 'oauth' # controller class OauthController < ApplicationController def new session[:token] = nil @@ -21,4 +26,4 @@ class OauthController < ApplicationController current_account.api_secret, oauth_callback_url(:host => current_account_canvas)) end end -
gamesthatgive created this gist
Nov 24, 2010 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ class OauthController < ApplicationController def new session[:token] = nil flash[:next] = params[:next] top_redirect_to authenticator.authorize_url(:scope => params[:scope], :display => :page) end def create # oauth callback is invoked if denied as well, so make sure we have a code if params[:code] client = Mogli::Client.create_from_code_and_authenticator(params[:code], authenticator) session[:token] = client.access_token end top_redirect_to flash[:next] end private def authenticator @authenticator ||= Mogli::Authenticator.new(current_account.app_id, current_account.api_secret, oauth_callback_url(:host => current_account_canvas)) end end