Class: OmniAuth::Strategies::Digitalocean
- Inherits:
-
OAuth2
- Object
- OAuth2
- OmniAuth::Strategies::Digitalocean
- Defined in:
- lib/omniauth/strategies/digitalocean.rb
Overview
Authenticate to DigitalOcean via OAuth and retrieve basic user information. Usage:
use OmniAuth::Strategies::Digitalocean, 'consumerkey', 'consumersecret', :scope => 'read write', :display => 'plain'
Constant Summary collapse
- AUTHENTICATION_PARAMETERS =
%w(display account state scope)
- BASE_URL =
"https://cloud.digitalocean.com"
- API_URL =
"https://api.digitalocean.com"
Instance Method Summary collapse
-
#authorize_params ⇒ Object
You can pass
display
,state
orscope
params to the auth request, if you need to set them dynamically. -
#callback_phase ⇒ Object
Hook used after response with code from provider.
-
#callback_url ⇒ Object
Over-ride callback_url definition to maintain compatability with omniauth-oauth2 >= 1.4.0.
- #raw_info ⇒ Object
-
#request_phase ⇒ Object
Hook useful for appending parameters into the auth url before sending to provider.
Instance Method Details
#authorize_params ⇒ Object
You can pass display
, state
or scope
params to the auth request, if you need to set them dynamically. You can also set these options in the OmniAuth config :authorize_params option.
/v1/auth/digialocean?display=fancy&state=ABC
77 78 79 80 81 82 83 |
# File 'lib/omniauth/strategies/digitalocean.rb', line 77 def super.tap do |params| AUTHENTICATION_PARAMETERS.each do |v| params[v.to_sym] = request.params[v] if request.params[v] end end end |
#callback_phase ⇒ Object
Hook used after response with code from provider. Used to prep token request from provider.
62 63 64 |
# File 'lib/omniauth/strategies/digitalocean.rb', line 62 def callback_phase super end |
#callback_url ⇒ Object
Over-ride callback_url definition to maintain compatability with omniauth-oauth2 >= 1.4.0
50 51 52 |
# File 'lib/omniauth/strategies/digitalocean.rb', line 50 def callback_url full_host + script_name + callback_path end |
#raw_info ⇒ Object
66 67 68 |
# File 'lib/omniauth/strategies/digitalocean.rb', line 66 def raw_info @raw_info ||= access_token.get("#{API_URL}/v2/account") end |
#request_phase ⇒ Object
Hook useful for appending parameters into the auth url before sending to provider.
56 57 58 |
# File 'lib/omniauth/strategies/digitalocean.rb', line 56 def request_phase super end |