/GrassrootsSurveyHerokuAuth0LoginApi

Express/Node.js/Heroku app to expose a login API that authenticate Auth0 user.

Primary LanguageJavaScript

Login API for Grassroots Mobile Survey App

Visit our wiki for the project details and further setup instructions.

Deploy

For further information on the projects Salesforce package see repo: @SFDO-Community-Sprints/GrassrootsSurveySalesforcePackage

For further information on the projects mobile app see repo: @SFDO-Community-Sprints/GrassrootsMobileSurveyApp

Setup

  1. Deploy this app to Heroku using above button.
  2. Open Auth0 app and enable [Password] authentication type at advanced settings section. Then add your users.
  3. Create an integration user in your Salesforce org.
  4. Open the Heroku app setting and set config variables for the integration user.

API Spec for Developers

POST /login

Request

  • Content-Type: application/json
  • Body:
{
    "email": "john@example.com",
    "password": "test1234!"
}

Reponsse

Success (200)
{
    "access_token": "00D28000000W2x5!AQQAQNTgJ_KyS9.BuohNq9_Awami_.OL9MiZe24bTt75Un56KChhd7lfJ2J.R_XdgP2cvx_clufew6i9acH8FKG9wacaDdgj",
    "instance_url": "https://YOUR_INSTANCE_OR_DOMAIN.salesforce.com"
}
Error (400, Environment variable is not set correctly)
{
    "error": "invalid_environment_variable",
    "error_description": "SALESFORCE_LOGIN_URL must end with '.salesforce.com'. Contact your administrator to see Heroku setting."
}
Error (403, Password realm is not setup yet)

Make sure that password type grant is enabled in your default auth0 app setting.

{
    "error": "unauthorized_client",
    "error_description": "Grant type 'http://auth0.com/oauth/grant-type/password-realm' not allowed for the client.",
    "error_uri": "https://auth0.com/docs/clients/client-grant-types"
}
Error (403, Invalid user email or password)

Make sure that your request is correct.

{
    "error": "invalid_grant",
    "error_description": "Wrong email or password."
}
Error (403, Invalid config variables)

Make sure that your config variables in Heroku setting are correct.

{
    "error": "invalid_salesforce_connection",
    "error_description": "INVALID_LOGIN: Invalid username, password, security token; or user locked out."
}