https://github.com/digitalocean/omniauth-digitalocean
DigitalOcean OAuth2 Strategy for OmniAuth
https://github.com/digitalocean/omniauth-digitalocean
digitalocean oauth omniauth ruby
Last synced: 7 months ago
JSON representation
DigitalOcean OAuth2 Strategy for OmniAuth
- Host: GitHub
- URL: https://github.com/digitalocean/omniauth-digitalocean
- Owner: digitalocean
- License: mit
- Created: 2014-04-11T15:30:24.000Z (almost 12 years ago)
- Default Branch: main
- Last Pushed: 2023-07-06T19:55:24.000Z (over 2 years ago)
- Last Synced: 2025-07-13T06:30:15.701Z (8 months ago)
- Topics: digitalocean, oauth, omniauth, ruby
- Language: Ruby
- Homepage: https://rubygems.org/gems/omniauth-digitalocean
- Size: 42 KB
- Stars: 29
- Watchers: 164
- Forks: 17
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# DigitalOcean's Omniauth strategy
This is the official Ruby OmniAuth strategy for authenticating to [DigitalOcean](https://www.digitalocean.com).
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.
## Installation
Add the strategy to your `Gemfile`:
```ruby
gem 'omniauth-digitalocean'
```
And bundle.
## Usage
You can integrate the strategy into your middleware in a `config.ru`:
```ruby
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:
```ruby
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](https://github.com/intridea/omniauth/wiki).
See the [example](https://github.com/digitaloceancloud/omniauth-digitalocean/blob/master/examples/sinatra/config.ru) Sinatra app for full examples
## Auth Hash Schema
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 user
* `info` - A hash containing information about the user
* `uuid` - The UUID of the authenticating user
* `name` - The user's display name
* `email` - The e-mail of the authenticating user
* `team_uuid` - The UUID of the team when authenticated in a team context
* `team_name` - The team's display name when authenticated in a team context
* `credentials` - A hash containing authentication information
* `token` - The DigitalOcean OAuth access token
* `refresh_token` - A refresh token that can be exchanged for a new OAuth access token
* `expires` - Boolean indicating whether the access token has an expiry date
* `expires_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 time
* `floating_ip_limit` - The total number of Floating IPs the current user or team may have
* `email` - The email address for the current user
* `uuid` - The UUID for the current user.
* `email_verified` - If true, the user has verified their account via email
* `status` - This value is one of `active`, `warning`, or `locked`
* `status_message` - A human-readable message giving more details about the status of the account
## License
omniauth-digitalocean is released under the MIT License.