diff --git a/README.md b/README.md index 690082e..767c7c4 100644 --- a/README.md +++ b/README.md @@ -234,13 +234,29 @@ To obtain your current profile:
Expand -* __NOTE:__ instead of performing the steps below you can instead use the "Settings - Strava" button in the launcher window to authorize (Windows and macOS only). -* [OPTIONAL] Get CLIENT_ID and CLIENT_SECRET from https://www.strava.com/settings/api +* Get CLIENT_ID and CLIENT_SECRET from https://www.strava.com/settings/api + +
Using launcher (Windows and macOS only) + +* Set the authorization callback domain of your API application to ``launcher.zwift.com`` +* Create a ``strava-api.txt`` file in the ``storage`` directory containing your client ID and secret +``` +CLIENT_ID +CLIENT_SECRET +``` +* Use the "Settings - Strava" button in the launcher window to authorize. + +
+ +
Using strava_auth script + * Run ``scripts/strava_auth.py --client-id CLIENT_ID --client-secret CLIENT_SECRET`` * Or, if using the Windows zoffline.exe version without Python installed you can run ``strava_auth.exe`` obtained from https://github.com/zoffline/zwift-offline/releases/tag/zoffline_helper in place of ``scripts/strava_auth.py`` - * Run without arguments to use default values. * Open http://localhost:8000/ and authorize. * Move the resulting ``strava_token.txt`` (saved in whatever directory you ran ``strava_auth.py`` in) into the ``storage/1`` directory. + +
+ * If testing, ride at least 300 meters, shorter activities won't be uploaded.
diff --git a/cdn/static/web/launcher/settings.html b/cdn/static/web/launcher/settings.html index c11fbe8..11ccdef 100644 --- a/cdn/static/web/launcher/settings.html +++ b/cdn/static/web/launcher/settings.html @@ -12,10 +12,12 @@ {% endif %} Power curves Zwift - {% if not token %} - Strava - {% else %} - Remove Strava token + {% if api %} + {% if not token %} + Strava + {% else %} + Remove Strava token + {% endif %} {% endif %} Garmin Intervals diff --git a/scripts/strava_auth.py b/scripts/strava_auth.py index 998415f..6869cd3 100755 --- a/scripts/strava_auth.py +++ b/scripts/strava_auth.py @@ -113,9 +113,9 @@ if __name__ == "__main__": parser.add_argument('-p', '--port', help='Which port to bind to', action='store', type=int, default=8000) parser.add_argument('--client-id', help='Strava API Client ID', - action='store', type=int, default=28117) + action='store', type=int, required=True) parser.add_argument('--client-secret', help='Strava API Client Secret', - action='store', default='41b7b7b76d8cfc5dc12ad5f020adfea17da35468') + action='store', required=True) args = parser.parse_args() main(port=args.port, client_id=args.client_id, client_secret=args.client_secret) diff --git a/zwift_offline.py b/zwift_offline.py index b58944b..3507a05 100644 --- a/zwift_offline.py +++ b/zwift_offline.py @@ -128,8 +128,11 @@ import warnings with warnings.catch_warnings(): from stravalib.client import Client -STRAVA_CLIENT_ID = 28117 -STRAVA_CLIENT_SECRET = '41b7b7b76d8cfc5dc12ad5f020adfea17da35468' +STRAVA_API_FILE = "%s/strava-api.txt" % STORAGE_DIR +if os.path.exists(STRAVA_API_FILE): + with open(STRAVA_API_FILE) as f: + STRAVA_CLIENT_ID = int(f.readline().rstrip('\r\n')) + STRAVA_CLIENT_SECRET = f.readline().rstrip('\r\n') from tokens import * @@ -942,8 +945,9 @@ def settings(username): if os.path.isfile(achievements_file): stat = os.stat(achievements_file) achievements = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(stat.st_mtime)) + api = os.path.isfile(STRAVA_API_FILE) token = os.path.isfile(os.path.join(profile_dir, 'strava_token.txt')) - return render_template("settings.html", username=current_user.username, profile=profile, achievements=achievements, token=token) + return render_template("settings.html", username=current_user.username, profile=profile, achievements=achievements, api=api, token=token) @app.route("/download/", methods=["GET"])