We offer access to our API via oAuth, allowing you to connect with Baremetrics users easily.

To begin, you will need to request access to our oAuth system. You can do so by reaching out to support, briefly explaining what you will be using our API for.

Once you have your Client ID and Client Secret, you can follow the standard oAuth 2.0 specification flow.

Send to Baremetrics

The first step is to send the user from your application to Baremetrics, using the following URL format.

You will need to specify response_type=code as a query param.

The scopes we offer are read and write. To allow both, use a space separated string.

https://app.baremetrics.com/oauth/authorize?client_id=CLIENT_ID&redirect_uri=REDIRECT_URL&scope=SCOPES&response_type=code

Request Access Token

Once the user has authenticated, they will be redirected back to your application with a code query parameter. You should use this code to request an access token for that user, for example:

RestClient.post("https://app.baremetrics.com/oauth/token", {
  'code' => code,
  'client_id' => CLIENT_ID,
  'client_secret' => CLIENT_SECRET,
  'grant_type' => 'authorization_code',
  'redirect_uri' => REDIRECT_URL
})

This will return you an Access Token that should then be passed into the Bearer Authentication header.