This is the official Ruby OmniAuth strategy for authenticating to DigitalOcean.
Before you can start developing your API client for DigitalOcean, you need to create an application on your account and copy the application id and secret.
Add the strategy to your Gemfile
:
gem 'omniauth-digitalocean'
And bundle.
You can integrate the strategy into your middleware in a config.ru
:
use OmniAuth::Builder do
provider :digitalocean, SETTINGS['CLIENT_ID'], SETTINGS['CLIENT_SECRET'], scope: "read write"
end
If you're using Rails, you'll want to add to the middleware stack:
Rails.application.config.middleware.use OmniAuth::Builder do
provider :digitalocean, SETTINGS['CLIENT_ID'], SETTINGS['CLIENT_SECRET'], scope: "read write"
end
- The scope needs to be separated by space and not comma: "read write" instead of "read,write" !
For additional information, refer to the OmniAuth wiki.
See the example Sinatra app for full examples
The following information is provided in the auth hash accessible to the callback at request.env["omniauth.auth"]
:
provider
- The OmniAuth provider, i.e.digitalocean
uid
- The UUID of the authenticating userinfo
- A hash containing information about the useruuid
- The UUID of the authenticating username
- The user's display nameemail
- The e-mail of the authenticating userteam_uuid
- The UUID of the team when authenticated in a team contextteam_name
- The team's display name when authenticated in a team context
credentials
- A hash containing authentication informationtoken
- The DigitalOcean OAuth access tokenrefresh_token
- A refresh token that can be exchanged for a new OAuth access tokenexpires
- Boolean indicating whether the access token has an expiry dateexpires_at
- Timestamp of the expiry time
extra
- Contains extra information returned from the/v2/account
endpoint of the DigitalOcean API.droplet_limit
- The total number of Droplets current user or team may have active at one timefloating_ip_limit
- The total number of Floating IPs the current user or team may haveemail
- The email address for the current useruuid
- The UUID for the current user.email_verified
- If true, the user has verified their account via emailstatus
- This value is one ofactive
,warning
, orlocked
status_message
- A human-readable message giving more details about the status of the account
omniauth-digitalocean is released under the MIT License.