Skip to Content
APIsAuthenticate to Grepr APIs

Authenticate to Grepr REST APIs

By default, most endpoints in the Grepr REST APIs are restricted and can be accessed only by using credentials with the required permissions. To obtain credentials, create a Grepr service account. See Manage Grepr service accounts.

The credentials consist of:

  • client ID: A unique identifier for your service account.
  • client secret: A secret key to authenticate your service account.

You use these these credentials to obtain an access token for API authentication.

The exception to the access restrictions for the Grepr APIs is the POST /v1/triggers endpoint to create external triggers.

Obtain an access token for Grepr REST APIs

Grepr uses Auth0  as the identity provider for authentication. To obtain an access token to use with Grepr APIs, you send a request to the token endpoint:

POST https://grepr-prod.us.auth0.com/oauth/token endpoint.

The following example submits a token request using the curl command. client-id and client-secret are the credentials from your service account:

curl --url https://grepr-prod.us.auth0.com/oauth/token \ --header 'content-type: application/json' \ --data '{ "client_id": "<client-id>", "client_secret": "<client-secret>", "audience": "service", "grant_type": "client_credentials" }'

Example response:

{ "access_token": "<access-token>", "token_type": "Bearer", "expires_in": "86400", "scope": "service" }
  • The access token has access to all APIs that Grepr provides to its customers. However, if you need to restrict access to specific APIs, you can reduce the access scope of a token. For help, contact support@grepr.ai.
  • The access token has a limited lifetime of 86400 seconds, which is equivalent to 24 hours. You must obtain a new token when it expires.
  • Keep the credentials you receive and the auth token secure. To prevent unauthorized access, do not expose these values in your client-side code or commit them to a version control repository.

Use the access token with the Grepr API

To authenticate against the Grepr APIs, include the access token as a Bearer token in the Authorization header of all API requests. If you submit a request using an expired token, a 401 Unauthorized response is returned, and you must obtain a new access token.

The following example uses the curl command to get all Asynchronous Streaming jobs from the jobs endpoint.

curl "https://<your_org_id>.app.grepr.ai/api/v1/jobs?processing=STREAMING&execution=ASYNCHRONOUS" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer <your_access_token>"

Example response:

{ "items": [ { "id": "0ABC123DEF456", "name": "Demo Job", "version": 0, "organizationId": "grepr", "execution": "ASYNCHRONOUS", "processing": "STREAMING", "state": "RUNNING", "desiredState": "RUNNING", "jobGraph": { "vertices": [], "edges": [] }, "createdAt": "2021-09-01T00:00:00Z", "updatedAt": "2021-09-01T00:00:00Z", "tags": { "createdUsing": "API", "createdByUser": "Hardworking Beaver" } } ] }
Last updated on