Authentication 🔗

POST /api/public/login/ HTTP/1.1
Host: app.crunch.io
Content-Type: application/json
Content-Length: 73

{
    "email": "fake.user@example.com",
    "password": "password",
    "token", true
}

HTTP/1.1 200 OK
{"access_token": "796f025f019ad8299337ba7b0924afbf", "token_type": "Bearer"}
library(crunch)
login("fake.user@example.com", "password")
# See ?login for options, including how to store your credentials
# in your .Rprofile
import pycrunch
curl -X POST
    -d '{"email": "fake.user@example.com", "password": "password", "token": true}'
    -H "Content-type: application/json"
    -H "Content-Length: 73"
    https://app.crunch.io/api/public/login/

# The above command will perform a login and return a Bearer Token.
# After this, you can access the endpoint via 'curl' commands (POST, GET, PATCH), as long as the '-H "Authorization: Bearer access_token' flag is present. Substitute 'access_token' with the one returned on the login request.

Nearly all interactions with the Crunch API need to be authenticated. The standard password authentication method involves POSTing credentials and requesting a Bearer token back, which should be included on further requests.

The client should then store the Bearer returned on the attribute access_token and pass it along with each subsequent request in the Authorization HTTP header.

Example:

  • Authorization: Bearer 796f025f019ad8299337ba7b0924afbf

Failure will return 401 Unauthorized.

Note

Replace “fake.user@example.com” and “password” with your email and password, respectively. Refer to the password policy below for more information. Replace the Bearer access token “796f025f019ad8299337ba7b0924afbf” on the Authorization header with the access_token returned from your login request.

Crunch also supports OAuth 2.0/OpenID Connect. See the public endpoint reference for more on how to authenticate with OAuth.

If you’d like to add your auth provider to the set of supported providers, contact support@crunch.io