I'm trying to set up an authentication via LinkedIn in the rails 5.2 application, for the same I'm referring to the documentation given by devise but I am getting the following error:
ERROR -- omniauth: (linkedin) Authentication failure! Connection reset by peer: Faraday::SSLError, Connection reset by peer
I have added these using the following gems for the configuration
- devise ~> 4.8.0
- omniauth-linkedin-oauth2 ~> 1.0.0
- omniauth ~> 2.0.4
I even tried running on the active domain in the production server which contains the valid SSL certificate but still, the same error is thrown.
Some informations about LinkedIn for you:
LinkedIn no longer supports the JavaScript SDK. The recommended approach is to use OAuth 2.0 and LinkedIn's Auth APIs.
And:
LinkedIn does not support TLS 1.0. Support for TLS 1.1 has been marked for deprecation starting 02/01/2020. Please use TLS 1.2 when calling LinkedIn APIs. All API requests to api.linkedin.com must be made over HTTPS. Calls made over HTTP will fail.
Step 1
: Add Jquery for Javascript library, run command:Then, set content of config/webpack/environment.js:
Step 2
: Create ssl connection by addthin
gemEdit
config/application.rb
and add:In project command line, type:
After these commands will create two file:
host.key
andhost.cert
. Then run:It will run project in default address: https://0.0.0.0:3000. If you want to run on https://localhost:3000, just type:
Step 3
: Create Linkedin oauth2 app.Go to link:
https://www.linkedin.com/developers/
Click the button
Create app
, then fill the informations to App name, LinkedIn Page (have to finish it by a custom page), App logo, Terms tick box. Then click to Create app to register your app.At Settings tab, set the domain of your app, I run with localhost so I will set
https://localhost:3000
.At Auth tab, save the Client ID and Client Secret to
config/application.yml
(remember to run commands$ bundle exec figaro install
before this) like these:Then edit, type and save to part Authorized redirect URLs for your app:
https://localhost:3000/auth/linkedin/callback
Check available scopes to use in this page! Mine is
r_emailaddress r_liteprofile
.At Products tab, select
Sign In with LinkedIn
, status will change toReview in progress
. All is ok if this status disappear after refresh F5 by a while!Step 4
: Set all codes like mine. With simpleconfig/routes.rb
:Create
app/controllers/linkedin_controller.rb
with content:Note to install these gems, and we don't need any oauth2 linkedin libs:
We will exit popup LinkedIn login by this callback view
app/views/linkedins/callback.html.erb
:Create this main view
app/views/linkedins/home.html.erb
:Successful screen: