# Intervals.icu OAuth support

**URL:** <https://forum.intervals.icu/t/intervals-icu-oauth-support/2759>\
**Category:** Announcements\
**Created:** [30 January 2021 14:51 UTC](https://forum.intervals.icu/t/intervals-icu-oauth-support/2759 "2021-01-30T14:51:05Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![david](https://forum.intervals.icu/user_avatar/forum.intervals.icu/david/32/30189_2.png) [@david](https://forum.intervals.icu/u/david)\
**Post date:** [30 January 2021 14:51 UTC](https://forum.intervals.icu/t/intervals-icu-oauth-support/2759/1 "2021-01-30T14:51:05Z")

</div>

Intervals.icu uses OAuth2 for authentication to the API. OAuth allows external applications to request authorization to access an Intervals.icu user’s data. It allows users to grant and revoke API access on a per-application basis and keeps user authentication details safe.

## Creating An Application

Fill in the application form here: [https://intervals.icu/oauth/apply](https://intervals.icu/oauth/apply)

You need to be logged in as the Intervals.icu athlete that will own the app. This athlete will have access to the management page to edit the app, setup redirect URI’s, webhooks and other things.

Your app will show up on the /settings/apps page (only for you as the owner) and you can click “Manage App” to retrieve your client\_id and secret, change redirect URL’s, configure webhooks and so on.

 ![Screenshot 2026-08-28 at 14.29.43](https://forum.intervals.icu/uploads/default/original/3X/2/3/2315938f281501f685fdbb3a1090b774f7a38bfd.png)

The app will have status “Pending” until it is approved. **Please note that you will not be able to do the OAuth flow until it is approved**. You can upload a logo, get the client ID and secret and so on.

Once it has been approved, the pending tag will disappear. You will receive a system notification when this happens (delivered by email and in the Intervals.icu app).

Note that it will not be visible to other users in /settings/apps, but you can send anyone you like to the OAuth consent page and begin integration.

 ![Screenshot 2024-12-06 at 16.38.05](https://forum.intervals.icu/uploads/default/original/3X/8/b/8b1c72e171adc3a90c2b8a21f06e9e5bb78e3942.png)

When you have completed your integration and tested properly, contact [support@intervals.icu](mailto:support@intervals.icu) to have it listed in the public app directory. Please include a link to the management page in the email.

## Requesting Authorization To Access Intervals.icu Data For A User

Send the user to:

```auto
https://intervals.icu/oauth/authorize?client_id=<your client id>
    &redirect_uri=<your redirect uri>
    &scope=<required scopes>
    &state=<optional data>

```

Intervals.icu will ask the user to login and display a confirmation dialog with options to choose which scopes to grant the application. If the user confirms then they are redirected to the redirect\_uri with an authorization code and the optional state parameter:

```auto
<your redirect uri>?code=3983ed415f66413c890ca48b7cce59e4&state=...

```

If they decline:

```auto
<your redirect uri>?error=access_denied

```

Your server needs to exchange the code for an access token within 2 minutes by POSTing form data including your client\_id and client\_secret:

```auto
curl -X POST https://intervals.icu/api/oauth/token \
    -d client_id=... \
    -d client_secret=... \
    -d code=3983ed415f66413c890ca48b7cce59e4

```

If all goes well Intervals.icu will respond with an access token, granted scopes and the id and name of the athlete:

```auto
{
    "token_type": "Bearer",
    "access_token": "d842c1fc25f241e5ae440d09756448a9",
    "scope": "ACTIVITY:WRITE,WELLNESS:WRITE",
    "athlete": {
        "id": "2049151",
        "name": "David (intervals.icu)"
    }
}   

```

To call the API use “Authorization: Bearer d842c1fc25f241e5ae440d09756448a9” header.

Note that you can use “0” for the athlete id for endpoints that accept an athlete id in the path. This will use the athlete for the bearer token used to make the call.

### PKCE (optional)

[PKCE](https://datatracker.ietf.org/doc/html/rfc7636) is supported to protect the authorization code from interception. Generate a random `code_verifier` (43-128 chars of `A-Z a-z 0-9 - . _ ~`) and add its challenge to the authorize URL (only `S256` is supported):

```auto
    &code_challenge=<BASE64URL(SHA256(code_verifier)) without padding>
    &code_challenge_method=S256

```

Then include `-d code_verifier=...` when exchanging the code. If a challenge was sent, the verifier is required, and a verifier is rejected if no challenge was sent. The client\_secret is still required unless your app is a public client.

Once every version of your app uses PKCE, tick “Require PKCE” on your app’s settings page. Authorizations without a code\_challenge are then rejected, and so is exchanging a code without a code\_verifier, even with the client\_secret.

### Public clients (SPA, mobile and desktop apps)

Apps that cannot keep a client\_secret confidential can be flagged as public clients on the OAuth app management page. Public clients that use PKCE can omit client\_secret when exchanging the code. Without PKCE the client\_secret is still required (this is supported so existing apps can migrate, please switch to PKCE). The automatic [http://localhost](http://localhost) redirect exception does not apply to public clients, so register the exact redirect URIs you use, including any localhost ones. The port of a registered [http://localhost](http://localhost) or [http://127.0.0.1](http://127.0.0.1) redirect is ignored, so native apps can listen on any free port:

```auto
curl -X POST https://intervals.icu/api/oauth/token \
    -d client_id=...
    -d code=3983ed415f66413c890ca48b7cce59e4
    -d code_verifier=...

```

## Scopes

Scopes are as follows:

- ACTIVITY: Completed rides, runs etc.
- WELLNESS: Weight, resting HR etc.
- CALENDAR: Planned workouts
- CHATS: Chats, groups and messages
- LIBRARY: Workout library
- SETTINGS: Athlete settings

For each scope specify READ or WRITE (to update, implies READ access) and use commas to separate multiple scopes. Example:

```auto
ACTIVITY:READ,WELLNESS:WRITE

```

Requests read access to activities and read and write access to wellness data.

## Revoking An Access Token

When a user disconnects Intervals.icu in your app or deletes their data on your side, revoke the access token:

```auto
curl -X DELETE "https://intervals.icu/api/v1/disconnect-app" \
 -H 'authorization: Bearer d842c1fc25f241e5ae440d09756448a9'

```

This will stop webhook delivery for the athlete.

## Coaching Apps

You can list athletes that the principal of the bearer token is coaching or following using `GET /api/v1/athletes` and access their data. However they need to explicitly opt in to sharing their data with apps authorised by others.

> [@Let your coaches' or followers' apps access your data](https://forum.intervals.icu/t/let-your-coachs-or-followers-apps-access-your-data/133622):
>
> Many of you use apps connected to Intervals.icu: training planners, analysis tools, AI coaches and so on. Until now an app could only see the data of the person who connected it. If your coach used an app to analyse their athletes, it could not see your data, even though your coach can see it on Intervals.icu. You can now choose to let apps used by your coaches, or by your coaches and followers, access your data. How to turn it on Go to Settings, open the Apps tab and change Who can access you…

## Your Own Data

Note that you don’t need to do all this if you just want access to your own data. Use your API key to do that.

## API Endpoints

> [@API access to Intervals.icu](https://forum.intervals.icu/t/api-access-to-intervals-icu/609):
>
> Intervals.icu now has a public API for other applications. To use it you need to generate an API key in /settings (look for “Developer Settings” near the bottom). Your API key allows other applications to access your Intervals.icu data. Be careful what you do with it! If you suspect that your key may have been compromised immediately clear or re-generate it. By using the API you agree to the [Intervals.icu API Terms and Conditions](https://forum.intervals.icu/t/intervals-icu-api-terms-and-conditions/114087) . Please not that data from Strava is not available from the API.…

---

<div class="post-metadata">

**Author:** ![david](https://forum.intervals.icu/user_avatar/forum.intervals.icu/david/32/30189_2.png) [@david](https://forum.intervals.icu/u/david)\
**Post date:** [30 January 2021 15:03 UTC](https://forum.intervals.icu/t/intervals-icu-oauth-support/2759/2 "2021-01-30T15:03:54Z")

</div>

This is what a user sees on the /settings page when they have authorised an app:

 ![Screen Shot 2021-01-30 at 17.00.16](https://forum.intervals.icu/uploads/default/original/2X/8/8f03060a46d7914e9881e6f90d24dff10560db6c.png)

Note that [HealthFit](https://apps.apple.com/us/app/healthfit/id1202650514) support for Intervals.icu is still in beta.

 ![Screen Shot 2021-01-30 at 17.00.46](https://forum.intervals.icu/uploads/default/original/2X/a/a5d2bc41708dfa9271521e865f0cfe7b684fd3db.png)

---

<div class="post-metadata">

**Author:** ![app4g](https://forum.intervals.icu/user_avatar/forum.intervals.icu/app4g/32/41800_2.png) [@app4g](https://forum.intervals.icu/u/app4g)\
**Post date:** [6 September 2021 14:30 UTC](https://forum.intervals.icu/t/intervals-icu-oauth-support/2759/3 "2021-09-06T14:30:54Z")

</div>

Hi David -

Just need confirmation. If we want (an app) to allow access to the user’s own data, there isn’t a need to use OAuth correct? Just the basic authentication bit would suffice?

> [@david](#):
>
> Note that you don’t need to do all this if you just want access to your own data. Use your API key to do that.

Thanks.

I’m working on possibly integrating my app to connect to intervals.icu’s API

Thanks.

---

<div class="post-metadata">

**Author:** ![John\_Peters\_endura.f](https://forum.intervals.icu/user_avatar/forum.intervals.icu/john_peters_endura.f/32/60975_2.png) [@John\_Peters\_endura.f](https://forum.intervals.icu/u/John_Peters_endura.f)\
**Post date:** [6 September 2021 14:36 UTC](https://forum.intervals.icu/t/intervals-icu-oauth-support/2759/4 "2021-09-06T14:36:20Z")

</div>

Was just about to ask the same question.

---

<div class="post-metadata">

**Author:** ![david](https://forum.intervals.icu/user_avatar/forum.intervals.icu/david/32/30189_2.png) [@david](https://forum.intervals.icu/u/david)\
**Post date:** [6 September 2021 15:39 UTC](https://forum.intervals.icu/t/intervals-icu-oauth-support/2759/5 "2021-09-06T15:39:11Z")

</div>

Yes if a user is only trying to get at their own data then they can just use basic auth and their API key. However if you are building something for lots of users it is better to do the oauth thing.

---

<div class="post-metadata">

**Author:** ![John\_Peters\_endura.f](https://forum.intervals.icu/user_avatar/forum.intervals.icu/john_peters_endura.f/32/60975_2.png) [@John\_Peters\_endura.f](https://forum.intervals.icu/u/John_Peters_endura.f)\
**Post date:** [6 September 2021 20:42 UTC](https://forum.intervals.icu/t/intervals-icu-oauth-support/2759/6 "2021-09-06T20:42:30Z")

</div>

I need to get my head round the oauth thing in R. If you don’t mind this would be a good test to connect this way to Intervals. I only get about 10 hits a day (EnDuRA is very niche!) plus I’d be sending people you way for full/longitudinal training planning and monitoring. I’ll send the proper request soon.

---

<div class="post-metadata">

**Author:** ![david](https://forum.intervals.icu/user_avatar/forum.intervals.icu/david/32/30189_2.png) [@david](https://forum.intervals.icu/u/david)\
**Post date:** [7 September 2021 04:31 UTC](https://forum.intervals.icu/t/intervals-icu-oauth-support/2759/7 "2021-09-07T04:31:12Z")

</div>

Cool. Its quite simple really: Just construct correct URL to send users to Intervals.icu to auth, then swap the code that comes back via the redirect URL for an access token.

---

<div class="post-metadata">

**Author:** ![John\_Peters\_endura.f](https://forum.intervals.icu/user_avatar/forum.intervals.icu/john_peters_endura.f/32/60975_2.png) [@John\_Peters\_endura.f](https://forum.intervals.icu/u/John_Peters_endura.f)\
**Post date:** [7 September 2021 06:45 UTC](https://forum.intervals.icu/t/intervals-icu-oauth-support/2759/8 "2021-09-07T06:45:24Z")

</div>

Thanks. Got a dummy app working with Strava api and oauth last night so think I get it.

---

<div class="post-metadata">

**Author:** ![david](https://forum.intervals.icu/user_avatar/forum.intervals.icu/david/32/30189_2.png) [@david](https://forum.intervals.icu/u/david)\
**Post date:** [7 September 2021 06:46 UTC](https://forum.intervals.icu/t/intervals-icu-oauth-support/2759/9 "2021-09-07T06:46:44Z")

</div>

Shot. Intervals.icu is a bit easier because it doesn’t use refresh tokens, only access tokens.

---

<div class="post-metadata">

**Author:** ![app4g](https://forum.intervals.icu/user_avatar/forum.intervals.icu/app4g/32/41800_2.png) [@app4g](https://forum.intervals.icu/u/app4g)\
**Post date:** [15 February 2022 10:43 UTC](https://forum.intervals.icu/t/intervals-icu-oauth-support/2759/10 "2022-02-15T10:43:14Z")

</div>

Is there a limitation for oAuth access to only be limited to one device at any one time?  
When I auth using my ipad, i can upload data. But when I do the same to my (already auth) iPhone. I have to re-auth again to be able to upload data.

I’ve never really delve down deeper why this is the case for intervals, DropBox and Strava seems to work for both devices.

---

<div class="post-metadata">

**Author:** ![david](https://forum.intervals.icu/user_avatar/forum.intervals.icu/david/32/30189_2.png) [@david](https://forum.intervals.icu/u/david)\
**Post date:** [15 February 2022 10:44 UTC](https://forum.intervals.icu/t/intervals-icu-oauth-support/2759/11 "2022-02-15T10:44:41Z")

</div>

Nothing that I am aware of. Intervals.icu only cares that the correct Bearer token is supplied, not where it is coming from.

---

<div class="post-metadata">

**Author:** ![app4g](https://forum.intervals.icu/user_avatar/forum.intervals.icu/app4g/32/41800_2.png) [@app4g](https://forum.intervals.icu/u/app4g)\
**Post date:** [15 February 2022 10:46 UTC](https://forum.intervals.icu/t/intervals-icu-oauth-support/2759/12 "2022-02-15T10:46:40Z")

</div>

I’ll check if the token is the same for both devices then.

---

<div class="post-metadata">

**Author:** ![app4g](https://forum.intervals.icu/user_avatar/forum.intervals.icu/app4g/32/41800_2.png) [@app4g](https://forum.intervals.icu/u/app4g)\
**Post date:** [15 February 2022 11:36 UTC](https://forum.intervals.icu/t/intervals-icu-oauth-support/2759/13 "2022-02-15T11:36:27Z")

</div>

Just checked. Seems like the Access Token is different between the ipad and the iphone w/ the same login. Is this expected?

Thanks

---

<div class="post-metadata">

**Author:** ![david](https://forum.intervals.icu/user_avatar/forum.intervals.icu/david/32/30189_2.png) [@david](https://forum.intervals.icu/u/david)\
**Post date:** [15 February 2022 19:40 UTC](https://forum.intervals.icu/t/intervals-icu-oauth-support/2759/14 "2022-02-15T19:40:43Z")

</div>

Hmm. I just had a look at the code and a new token is generated each time a user auths an app and this replaces whatever token might already exist. I could return the existing token if there is one for the app. I wonder if there are any security implications?

---

<div class="post-metadata">

**Author:** ![Matthew\_Roche](https://forum.intervals.icu/user_avatar/forum.intervals.icu/matthew_roche/32/2937_2.png) [@Matthew\_Roche](https://forum.intervals.icu/u/Matthew_Roche)\
**Post date:** [17 April 2022 07:08 UTC](https://forum.intervals.icu/t/intervals-icu-oauth-support/2759/15 "2022-04-17T07:08:57Z")

</div>

For those trying to use this login flow for mobile apps, storing the client secret within your app is a security vulnerability as the secret can be read from the API calls your app makes during the login process. I have developed an AWS Lambda script to proxy the OAuth calls and keep the client secret secure. If this is useful to anyone in the future it is here: [Python OAuth flow for Intervals.icu Lambda · GitHub](https://gist.github.com/matthewroche/a551b32126608c816825746fc842389f)

---

<div class="post-metadata">

**Author:** ![Matthew\_Roche](https://forum.intervals.icu/user_avatar/forum.intervals.icu/matthew_roche/32/2937_2.png) [@Matthew\_Roche](https://forum.intervals.icu/u/Matthew_Roche)\
**Post date:** [17 April 2022 07:11 UTC](https://forum.intervals.icu/t/intervals-icu-oauth-support/2759/16 "2022-04-17T07:11:07Z")

</div>

I’ve noticed this to be a problem too David, I can’t see any problem returning an existing token but I’m no security expert…

---

<div class="post-metadata">

**Author:** ![app4g](https://forum.intervals.icu/user_avatar/forum.intervals.icu/app4g/32/41800_2.png) [@app4g](https://forum.intervals.icu/u/app4g)\
**Post date:** [24 April 2022 08:22 UTC](https://forum.intervals.icu/t/intervals-icu-oauth-support/2759/17 "2022-04-24T08:22:53Z")

</div>

If I read it correctly, you’re saying that your app (fitnessFatigue) uses this script that is hosted on AWS Lambda to get the accessTokens back to your app?

eg:  
Your App → Call Login → Login page triggers the AWS Lambda script → AWS Lambda script executes and then returns the access token → Your App

Is that the flow?

I just took at look at AWS Lambda, basically you need an account as well as pay some amount of money for this service correct?

> [@Matthew\_Roche](#):
>
> I’ve noticed this to be a problem too David, I can’t see any problem returning an existing token but I’m no security expert…

You’re storing your access token in the iCloud KeyChain correct? I’m no security expert either, but it’s a lot better than me rolling my own. Plus, now 1 token for all devices seems to work.

---

<div class="post-metadata">

**Author:** ![Matthew\_Roche](https://forum.intervals.icu/user_avatar/forum.intervals.icu/matthew_roche/32/2937_2.png) [@Matthew\_Roche](https://forum.intervals.icu/u/Matthew_Roche)\
**Post date:** [25 April 2022 19:05 UTC](https://forum.intervals.icu/t/intervals-icu-oauth-support/2759/18 "2022-04-25T19:05:36Z")

</div>

Hi, thank for your reply.

Yep, you do need to pay to use AWS, but there is a free tier of one million requests per month…

You’re absolutely right about the login flow. The “Redirect URI” that you provide when you sign up should link to the Lambda script. The code on line 76 links back to your app using [a custom URL].([Apple Developer Documentation](https://developer.apple.com/documentation/xcode/defining-a-custom-url-scheme-for-your-app))

As you say, the access token is stored in Keychain for security.

---

<div class="post-metadata">

**Author:** ![pmcarlos](https://forum.intervals.icu/user_avatar/forum.intervals.icu/pmcarlos/32/29082_2.png) [@pmcarlos](https://forum.intervals.icu/u/pmcarlos)\
**Post date:** [30 August 2022 21:30 UTC](https://forum.intervals.icu/t/intervals-icu-oauth-support/2759/19 "2022-08-30T21:30:30Z")

</div>

@david Does this `access_token` expire eventually? I’m getting 403 after a couple of hours or so. It could be due to testing in different devices multiple times, but wanna be sure  
Also, what happens with the access\_token if user logins in another device, does the old one expires?

---

<div class="post-metadata">

**Author:** ![app4g](https://forum.intervals.icu/user_avatar/forum.intervals.icu/app4g/32/41800_2.png) [@app4g](https://forum.intervals.icu/u/app4g)\
**Post date:** [30 August 2022 21:46 UTC](https://forum.intervals.icu/t/intervals-icu-oauth-support/2759/20 "2022-08-30T21:46:17Z")

</div>

AFAIK, the token is once-off (never had to re-login to get a new one)  
Whenever a new login is detected, a new token gets generated and that would be the token that has to be used across all your devices. The old one is discarded.

Intervals.icu only generates 1 single token for all your devices, so in order to be able to access, you need to share this token across all your devices.

On My App, I am using the user’s encrypted keychain. Most of these were discussed in just a few posts above.

[Next page](https://forum.intervals.icu/t/intervals-icu-oauth-support/2759.md?page=2)
