README.md in omniauth-bungie-oauth2-0.1.2 vs README.md in omniauth-bungie-oauth2-1.0
- old
+ new
@@ -7,50 +7,50 @@
## Installation
Add this line to your application's Gemfile:
-```ruby
+~~~~ruby
gem 'omniauth-bungie-oauth2'
-```
+~~~~
And then execute:
$ bundle
## Usage
### Settings
-For full usage this gem You must create an application with authentication access on [Bungie.net](https://www.bungie.net/en/application).
+For usage this gem You must create an application with authentication access on [Bungie.net](https://www.bungie.net/en/application).
+You should set **Confidential** value in the `OAuth Client Type` field.
After this, you can integrate this strategy with your application. (More about A Bungie OAuth2 you can read on [Help page](https://www.bungie.net/en/Help/Article/45481))
-For example, you can add the middleware to a Rails application in `/config/application.rb`:
+**This provider uses four arguments:**
-~~~ruby
-config.middleware.use OmniAuth::Builder do
- provider :bungie,
- 'x_api_key_from_bungie_app_settings',
- 'authorization_url_from_bungie_app_settings',
- :origin => 'origin_url_if_you_need'
-end
-~~~~
+* `client_id` - OAuth client_id,
+* `client_secret` - OAuth client_secret,
+* `x_api_key` - API Key,
+* `redirect_uri` - Redirect URL.
### Rails integration
For integration with Rails You have to setup your strategy configuration in `config/initializers/devise.rb`:
~~~~ruby
Devise.setup do |config|
config.omniauth :bungie,
- 'x_api_key_from_bungie_app_settings',
- 'authorization_url_from_bungie_app_settings',
- :origin => 'origin_url_if_you_need'
+ 'client_id',
+ 'client_secret',
+ 'x_api_key',
+ 'redirect_url'
end
~~~~
+> You can also define it in initializers with `config.middleware.use OmniAuth::Builder`.
+
After this You should define omniauth callback in routes and controller.
**routes.rb:**
~~~~ruby
@@ -76,31 +76,33 @@
session["devise.bungie_data"] = request.env["omniauth.auth"]
redirect_to '/'
end
end
+end
+~~~~
- def failure
- redirect_to '/'
+Now You should define `from_omniauth` method in your `User` model:
+
+~~~~ruby
+def self.from_omniauth(auth)
+ where(:uid => auth.uid).first_or_create do |user|
+ user.membership_id = auth.info.membership_id
+ user.display_name = auth.info.display_name
+ user.unique_name = auth.info.unique_name
end
end
~~~~
+> Do not forget to specify model fields in your migration.
+
### Result
After all manipulation the `request.env["omniauth.auth"]` have the next fields:
* `uid` with BungieNetUser membershipId
-* `info` with Destiny membershipId, membershipType and displayName
-* `extra` with [GetBungieAccount](https://destinydevs.github.io/BungieNetPlatform/docs/UserService/GetBungieAccount) result
-
-## Configuration
-
-This provider require two arguments and have one special option:
-
-* `api_key` - X-Api-Key for Bungie API;
-* `auth_url` - Autherization url;
-* `origin` - Origin url;
+* `info` with membershipId, uniqueName, displayName
+* `extra` with [GetCurrentBungieNetUser](https://destinydevs.github.io/BungieNetPlatform/docs/UserService/GetCurrentBungieNetUser) result
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/RuBAN-GT/omniauth-bungie-oauth2. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.