How to fix ERROR -- omniauth: (linkedin) Authentication failure! invalid_credentials: OAuth2::Error, {"serviceErrorCode":100,"message":"Not enough permissions to access: GET /me","status":403}

Zahid Ali 0 Reputation points
2023-10-31T11:12:56.43+00:00

I am facing an error ERROR -- omniauth: (linkedin) Authentication failure! invalid_credentials: OAuth2::Error, {"serviceErrorCode":100,"message":"Not enough permissions to access: GET /me","status":403}.
I make an app on linkedIn and verified it. Get the sign in with openId connect product and generate token that give me three scopes, profile, email and openid from where openid not work but others work.
Then i set credentials and all requirments that linkedin needed, that is omniauth controller, and conf in devise.rb is following

 Rails.application.config.middleware.use OmniAuth::Builder do
    OmniAuth.config.allowed_request_methods = [:post, :get]
    
    provider :linkedin, Rails.application.credentials[:linkedin][:CLIENT_ID],
    Rails.application.credentials[:linkedin][:CLIENT_SECRET]
  end

def linkedin
    @user = User.from_omniauth(request.env["omniauth.auth"])
    if @user.persisted?
      flash[:notice] = I18n.t "devise.omniauth_callbacks.success", kind: "LinkedIn"
      sign_in_and_redirect @user, event: :authentication
    else
      session["devise.facebook_data"] = request.env["omniauth.auth"].except("extra")
      redirect_to new_user_registration_url, alert: @user.errors.full_messages.join("\n")
    end
  end
Not Monitored
Not Monitored
Tag not monitored by Microsoft.
32,917 questions
{count} votes