mirror of
https://github.com/zoffline/zwift-offline.git
synced 2026-06-12 11:01:32 -07:00
Update Strava authorization (#323)
This commit is contained in:
@@ -234,13 +234,29 @@ To obtain your current profile:
|
||||
|
||||
<details><summary>Expand</summary>
|
||||
|
||||
* __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
|
||||
|
||||
<details><summary>Using launcher (Windows and macOS only)</summary>
|
||||
|
||||
* 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.
|
||||
|
||||
</details>
|
||||
|
||||
<details><summary>Using strava_auth script</summary>
|
||||
|
||||
* 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.
|
||||
|
||||
</details>
|
||||
|
||||
* If testing, ride at least 300 meters, shorter activities won't be uploaded.
|
||||
|
||||
</details>
|
||||
|
||||
@@ -12,10 +12,12 @@
|
||||
{% endif %}
|
||||
<a href="{{ url_for('power_curves', username=username) }}" class="btn btn-sm btn-secondary">Power curves</a>
|
||||
<a href="{{ url_for('profile', username=username) }}" class="btn btn-sm btn-secondary">Zwift</a>
|
||||
{% if not token %}
|
||||
<a href="{{ url_for('strava') }}" class="btn btn-sm btn-secondary">Strava</a>
|
||||
{% else %}
|
||||
<a href="/delete/strava_token.txt" class="btn btn-sm btn-danger">Remove Strava token</a>
|
||||
{% if api %}
|
||||
{% if not token %}
|
||||
<a href="{{ url_for('strava') }}" class="btn btn-sm btn-secondary">Strava</a>
|
||||
{% else %}
|
||||
<a href="/delete/strava_token.txt" class="btn btn-sm btn-danger">Remove Strava token</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
<a href="{{ url_for('garmin', username=username) }}" class="btn btn-sm btn-secondary">Garmin</a>
|
||||
<a href="{{ url_for('intervals', username=username) }}" class="btn btn-sm btn-secondary">Intervals</a>
|
||||
|
||||
@@ -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)
|
||||
|
||||
+7
-3
@@ -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/<filename>", methods=["GET"])
|
||||
|
||||
Reference in New Issue
Block a user