|
| 1 | +# OmniAuth LinkedIn |
| 2 | + |
| 3 | + |
| 4 | +[](https://rubygems.org/gems/omniauth-linkedin-openid) |
| 5 | + |
| 6 | +This is the a OmniAuth strategy for authenticating to LinkedIn using OpenID. To |
| 7 | +use it, you'll need to register an application on the |
| 8 | +[LinkedIn Apps Page](https://www.linkedin.com/developers/apps) to get your |
| 9 | +Client ID and Client Secret. Additionally, you'll need to request access to the |
| 10 | +"Sign In with LinkedIn using OpenID Connect" product. |
| 11 | + |
| 12 | +For more details, read the [Sign In with LinkedIn using OpenID Connect](https://learn.microsoft.com/en-us/linkedin/consumer/integrations/self-serve/sign-in-with-linkedin-v2) documentation. |
| 13 | + |
| 14 | +## Installation |
| 15 | + |
| 16 | +```ruby |
| 17 | +gem 'omniauth-linkedin-openid' |
| 18 | +``` |
| 19 | + |
| 20 | +## Usage |
| 21 | + |
| 22 | +```ruby |
| 23 | +use OmniAuth::Builder do |
| 24 | + provider :linkedin, ENV['LINKEDIN_CLIENT_ID'], ENV['LINKEDIN_CLIENT_SECRET'] |
| 25 | +end |
| 26 | +``` |
| 27 | + |
| 28 | +## Authenticating Members |
| 29 | + |
| 30 | +With the LinkedIn API, you have the ability to specify which permissions you want users to grant your application. For more details, read the LinkedIn [Authenticating Members](https://learn.microsoft.com/en-us/linkedin/consumer/integrations/self-serve/sign-in-with-linkedin-v2#authenticating-members) documentation. |
| 31 | + |
| 32 | +The following scopes are requested by default: |
| 33 | + |
| 34 | +'openid profile email' |
| 35 | + |
| 36 | +Here is an example of how you can configure the `scope` option: |
| 37 | + |
| 38 | +```ruby |
| 39 | +provider :linkedin, ENV['LINKEDIN_CLIENT_ID'], ENV['LINKEDIN_CLIENT_SECRET'], |
| 40 | + scope: 'openid profile email' |
| 41 | +``` |
| 42 | + |
| 43 | +## Profile Fields |
| 44 | + |
| 45 | +When specifying which permissions you want users to grant to your application, you can also specify the array of fields that you want returned in the OmniAuth hash. The following fields are requested by default: |
| 46 | + |
| 47 | +```ruby |
| 48 | +%w(id full-name first-name last-name picture-url email-address) |
| 49 | +``` |
| 50 | + |
| 51 | +Here is an example of how you can configure the `fields` option: |
| 52 | + |
| 53 | +```ruby |
| 54 | +provider :linkedin, ENV['LINKEDIN_CLIENT_ID'], ENV['LINKEDIN_CLIENT_SECRET'], |
| 55 | + fields: %w(id full-name email-address) |
| 56 | +``` |
| 57 | + |
| 58 | +To see a complete list of available fields, read the LinkedIn [Profile Fields](https://learn.microsoft.com/en-us/linkedin/shared/references/fields) documentation. |
| 59 | + |
| 60 | +## Development |
| 61 | + |
| 62 | +After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. |
| 63 | + |
| 64 | +## Contributing |
| 65 | + |
| 66 | +Bug reports and pull requests are welcome on GitHub at https://github.com/jclusso/omniauth-linkedin-openid. |
| 67 | + |
| 68 | +## License |
| 69 | + |
| 70 | +The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT). |
| 71 | + |
| 72 | +## Credits |
| 73 | + |
| 74 | +Thanks to [@decioferreira](https://github.com/decioferreira) for making [omniauth-linkedin-oauth2](https://github.com/decioferreira/omniauth-linkedin-oauth2) which this was based on. |
0 commit comments