-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update to MLH API v4 - Update endpoints to use v4 API - Add support for expandable fields - Update scopes to use new granular system - Configure auth params to use request body - Document offline_access scope for refresh tokens * Update to MLH API v4 - Update endpoints to use v4 API - Add support for expandable fields - Update scopes to use new granular system - Configure auth params to use request body - Document offline_access scope for refresh tokens - Add deep symbolization for nested arrays - Include all fields from user object schema * test: Add comprehensive test coverage for v4 API - Added ActiveSupport for deep symbolization - Updated test structure for v4 API compatibility - Improved SimpleCov configuration - Increased line coverage to 80.49% - Added branch coverage tracking Link to Devin run: https://preview.devin.ai/devin/3be39d31a19840d9ae7b7bebabe8c9c6 * test: Increase test coverage from 80.49% to 87.8% - Add tests for complex nested arrays and hashes - Add tests for hash pruning with nil values - Add tests for completely empty hashes - Add tests for version constant and module loading - Add explicit tests for uid method - Fix spec_helper.rb to properly load all files * Replace subject with strategy in tests to fix RSpec/NamedSubject violations * Apply RuboCop auto-corrections for code style improvements * Fix RuboCop offenses and improve test infrastructure - Refactored MLH strategy for better code organization - Fixed hash indentation in shared examples - Replaced unverified doubles with instance_double - Moved spec files to correct directory structure - All tests passing with 88.64% line coverage * We don't need to support Ruby 2.7 * Update gem version to 2.0 * Correct json parsing * fix: properly handle data wrapper in API response and update test infrastructure * Revert "fix: properly handle data wrapper in API response and update test infrastructure" This reverts commit 6cafa4e. * fix: update test doubles to match strategy implementation * style: fix argument alignment in spec file * rubocop formatting * add line breaks as per Rashika's request * Change the style as per Rashika's request in #16 (comment) * Update the README for v4 * add example for accessing user data * README formatting fix --------- Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
- Loading branch information
Showing
9 changed files
with
399 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,17 +4,16 @@ | |
[![Test](https://github.com/MLH/omniauth-mlh/actions/workflows/test.yml/badge.svg)](https://github.com/MLH/omniauth-mlh/actions/workflows/test.yml) | ||
|
||
This is the official [OmniAuth](https://github.com/omniauth/omniauth) strategy for | ||
authenticating with [MyMLH](https://my.mlh.io). To use it, you'll need to | ||
[register an application](https://my.mlh.io/oauth/applications) and obtain a OAuth Application ID and Secret from MyMLH. | ||
authenticating with [MyMLH](https://my.mlh.io) in Ruby applications. To use it, you'll need to | ||
[register an application](https://my.mlh.io/developers) and obtain a OAuth Application ID and Secret from MyMLH. | ||
|
||
It now supports MyMLH API V3. [Read the MyMLH V3 docs here](https://my.mlh.io/docs). | ||
It now supports MyMLH API V4. [Read the MyMLH V4 docs here](https://my.mlh.io/developers/docs). | ||
|
||
Once you have done so, you can follow the instructions below: | ||
|
||
## Requirements | ||
|
||
This Gem requires your Ruby version to be at least `2.2.0`, which is set | ||
downstream by [Omniauth](https://github.com/omniauth/omniauth/blob/master/omniauth.gemspec#L22). | ||
This Gem requires your Ruby version to be at least `3.2.0`. | ||
|
||
## Installation | ||
|
||
|
@@ -34,9 +33,13 @@ Or install it yourself as: | |
|
||
## Usage (Rack) | ||
|
||
You can find a list of potential scopes and expandable fields in the [docs](https://my.mlh.io/developers/docs). The below defaults are provided simply as an example. | ||
|
||
```ruby | ||
use OmniAuth::Builder do | ||
provider :mlh, ENV['MY_MLH_KEY'], ENV['MY_MLH_SECRET'], scope: 'default email birthday' | ||
provider :mlh, ENV['MY_MLH_KEY'], ENV['MY_MLH_SECRET'], | ||
scope: 'public offline_access user:read:profile', | ||
expand_fields: ['education'] | ||
end | ||
``` | ||
|
||
|
@@ -46,10 +49,27 @@ end | |
# config/devise.rb | ||
|
||
Devise.setup do |config| | ||
config.provider :mlh, ENV['MY_MLH_KEY'], ENV['MY_MLH_SECRET'], scope: 'default email birthday' | ||
config.provider :mlh, ENV['MY_MLH_KEY'], ENV['MY_MLH_SECRET'], | ||
scope: 'public offline_access user:read:profile', | ||
expand_fields: ['education'] | ||
end | ||
``` | ||
|
||
## Accessing User Data | ||
Once a user has been authorized and you have received a token in your callback, you may access the scoped information for that user via the info key on the request data, as per the below example from a simple Sinatra app: | ||
|
||
```ruby | ||
get '/auth/mlh/callback' do | ||
auth = request.env['omniauth.auth'] | ||
user_data = auth['info'] | ||
first_name = user_data['first_name'] | ||
erb " | ||
<h1>Hello #{first_name}</h1>" | ||
end | ||
``` | ||
|
||
You can find the full User object in the [docs](https://my.mlh.io/developers/docs). | ||
|
||
## Contributing | ||
|
||
For guidance on setting up a development environment and how to make a contribution to omniauth-mlh, see the [contributing guidelines](https://github.com/MLH/omniauth-mlh/blob/main/CONTRIBUTING.md). | ||
|
@@ -61,6 +81,6 @@ We used part of [datariot/omniauth-paypal](http://github.com/datariot/omniauth-p | |
## Questions? | ||
|
||
Have a question about the API or this library? Start by checking out the | ||
[official MyMLH documentation](https://my.mlh.io/docs). If you still can't | ||
[official MyMLH documentation](https://my.mlh.io/developers/docs). If you still can't | ||
find an answer, tweet at [@MLHacks](http://twitter.com/mlhacks) or drop an | ||
email to [[email protected]](mailto:[email protected]). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,6 @@ | |
|
||
module OmniAuth | ||
module MLH | ||
VERSION = '1.0.1' | ||
VERSION = '4.0.0' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.