This is a .NET console application that allows you to take an existing .gpx file, specify a new start timestamp, and upload it directly to your Strava account. The application will automatically parse the XML of the GPX file and shift the timestamp of every single trackpoint to align with your new start time, ensuring your activity appears correctly on Strava.
It also supports optionally spoofing or overriding the "Device Name" that appears on the Strava activity page.
- Smart Time Shifting: Calculates the exact offset needed and applies it to all
<time>elements in the GPX file. - Direct Strava Upload: Uses the Strava API
POST /uploadsendpoint to upload the modified file without needing manual intervention. - Device Name Spoofing: Optionally injects a custom device name (e.g., "Apple Watch Ultra 2", "Garmin Edge 530") into the GPX
creatorattribute so it displays on Strava. - Batch Selection: Reads from a local
GPX/folder and allows you to select which file to process via a simple console prompt.
Ensure you have a folder named GPX in the same directory as the executable. Place any .gpx files you wish to process into this folder.
To use this tool, you must configure your own Strava API credentials in appsettings.json.
- Go to your Strava API settings: https://www.strava.com/settings/api
- Create an API Application if you haven't already.
- Copy your Client ID and Client Secret.
By default, the token on your Strava API settings page only has read access. To upload activities, you need a token with the activity:write scope.
Follow these steps to generate a valid Refresh Token:
-
Construct the Authorization URL: Open a web browser and go to this exact URL (replace
[YOUR_CLIENT_ID]with your actual Client ID):http://www.strava.com/oauth/authorize?client_id=[YOUR_CLIENT_ID]&response_type=code&redirect_uri=http://localhost/exchange_token&approval_prompt=force&scope=activity:write -
Authorize the App: Click "Authorize" on the Strava page that appears.
-
Get the Authorization Code: You will be redirected to a URL that looks like a broken page (e.g.,
http://localhost/exchange_token?state=&code=a1b2c3d4e5f6...&scope=read,activity:write). Look at the URL in your address bar and copy the value of thecodeparameter. -
Exchange for a Refresh Token: Make a POST request to exchange that code for a token. You can run this in PowerShell:
Invoke-RestMethod -Uri "https://www.strava.com/oauth/token" -Method Post -Body @{ client_id = "YOUR_CLIENT_ID"; client_secret = "YOUR_CLIENT_SECRET"; code = "THE_CODE_YOU_COPIED"; grant_type = "authorization_code" }
-
Update Configuration: Take the
refresh_tokenfrom the JSON response and place it in yourappsettings.json.
Your appsettings.json should look like this:
{
"Strava": {
"ClientId": "YOUR_CLIENT_ID",
"ClientSecret": "YOUR_CLIENT_SECRET",
"RefreshToken": "YOUR_NEW_REFRESH_TOKEN"
}
}- Open a terminal in the project directory.
- Run the application:
dotnet run
- Follow the interactive console prompts:
- Select the GPX file from the list.
- Enter the new start timestamp (format:
yyyy-MM-dd HH:mm:ss). - (Optional) Enter a custom device name.