Class: Google::Auth::WebUserAuthorizer::CallbackApp
- Inherits:
-
Object
- Object
- Google::Auth::WebUserAuthorizer::CallbackApp
- Defined in:
- lib/googleauth/web_user_authorizer.rb
Overview
Small Rack app which acts as the default callback handler for the app.
To configure in Rails, add to routes.rb:
match '/oauth2callback',
to: Google::Auth::WebUserAuthorizer::CallbackApp,
via: :all
With Rackup, add to config.ru:
map '/oauth2callback' do
run Google::Auth::WebUserAuthorizer::CallbackApp
end
Or in a classic Sinatra app:
get('/oauth2callback') do
Google::Auth::WebUserAuthorizer::CallbackApp.call(env)
end
Constant Summary collapse
- LOCATION_HEADER =
'Location'.freeze
- REDIR_STATUS =
302
- ERROR_STATUS =
500
Class Method Summary collapse
-
.call(env) ⇒ Array
Handle a rack request.
Instance Method Summary collapse
Class Method Details
.call(env) ⇒ Array
Handle a rack request. Simply stores the results the authorization in the session temporarily and redirects back to to the previously saved redirect URL. Credentials can be later retrieved by calling. Google::Auth::Web::WebUserAuthorizer#get_credentials
See Google::Auth::Web::WebUserAuthorizer#get_authorization_uri for how to initiate authorization requests.
278 279 280 281 282 283 284 285 286 |
# File 'lib/googleauth/web_user_authorizer.rb', line 278 def self.call(env) request = Rack::Request.new(env) return_url = WebUserAuthorizer.handle_auth_callback_deferred(request) if return_url [REDIR_STATUS, { LOCATION_HEADER => return_url }, []] else [ERROR_STATUS, {}, ['No return URL is present in the request.']] end end |
Instance Method Details
#call(env) ⇒ Object
288 289 290 |
# File 'lib/googleauth/web_user_authorizer.rb', line 288 def call(env) self.class.call(env) end |