A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/mlh/omniauth-mlh below:

MLH/omniauth-mlh: OmniAuth strategy for MyMLH

This is the official OmniAuth strategy for authenticating with MyMLH in Ruby applications. To use it, you'll need to register an application and obtain a OAuth Application ID and Secret from MyMLH.

It now supports MyMLH API V4. Read the MyMLH V4 docs here.

Once you have done so, you can follow the instructions below:

This Gem requires your Ruby version to be at least 3.2.0.

Add this line to your application's Gemfile:

And then execute:

Or install it yourself as:

$ gem install omniauth-mlh

You can find a list of potential scopes and expandable fields in the docs. The below defaults are provided simply as an example.

use OmniAuth::Builder do
  provider :mlh, ENV['MY_MLH_KEY'], ENV['MY_MLH_SECRET'],
    scope: 'public offline_access user:read:profile',
    expand_fields: ['education']
end
Usage (Rails with Devise)
# config/devise.rb

Devise.setup do |config|
  config.provider :mlh, ENV['MY_MLH_KEY'], ENV['MY_MLH_SECRET'],
    scope: 'public offline_access user:read:profile',
    expand_fields: ['education']
end

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:

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.

For guidance on setting up a development environment and how to make a contribution to omniauth-mlh, see the contributing guidelines.

We used part of datariot/omniauth-paypal's code to help us test this gem.

Have a question about the API or this library? Start by checking out the official MyMLH documentation. If you still can't find an answer, tweet at @MLHacks or drop an email to engineering@mlh.io.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4