Flow Logo

Interacting with Flow.bio programmatically

Authentication

Flow uses access tokens and refresh tokens to authenticate incoming requests. Any request which needs to be sent as a logged in user must have an access token in its HTTP headers. These short-lived tokens are obtained from specific endpoints if a long-lived refresh token is sent as a cookie.

Using the flowbio library?

The flowbio library handles authentication automatically. You only need to understand this if you are making direct REST API requests.


Getting API tokens via the UI

The easiest way to get an access token, is to create one via the UI. You can do this by going to the Account Management tab under Settings in the UI.


Getting refresh and access tokens via the API using username and password

Refresh tokens

A refresh token is a JWT, stored in an HTTP-only cookie on the client. It lasts for one year, and any client with this cookie can obtain an access token at any time.

Refresh tokens are obtained from the /login endpoint:

curl -X POST https://app.flow.bio/api/login \
     -H "Content-Type: application/json" \
     -d '{"username": "yourUsername", "password": "yourPassword"}'

Assuming the credentials are correct, the HTTP response will set an HTTP-only cookie on the sending client.

Access tokens

An access token is a JWT string which lasts for thirty minutes. It can be obtained from the /token endpoint:

curl -X GET "https://app.flow.bio/api/token" \
     -b "flow_refresh_token=YOUR_REFRESH_TOKEN_VALUE"

The access token returned should be sent in the header of any request that is to be authenticated:

curl -X GET "https://app.flow.bio/api/me" \
     -H "Authorization: Bearer YOUR_ACCESS_TOKEN"

Note that the /login endpoint also returns an access token, so unless you are refreshing it later you may be able to skip the /token request.

Previous
API Overview