sweatstack 0.36.0__py3-none-any.whl → 0.37.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
sweatstack/schemas.py CHANGED
@@ -1,5 +1,5 @@
1
1
  from enum import Enum
2
2
 
3
3
  from .openapi_schemas import (
4
- ActivityDetails, ActivitySummary, Metric, Sport, TraceDetails, UserInfoResponse, UserSummary
4
+ ActivityDetails, ActivitySummary, Metric, Scope, Sport, TraceDetails, UserInfoResponse, UserSummary
5
5
  )
sweatstack/streamlit.py CHANGED
@@ -1,6 +1,7 @@
1
1
  import os
2
2
  import urllib.parse
3
3
  from datetime import date
4
+ from typing import List, Union
4
5
  try:
5
6
  import streamlit as st
6
7
  except ImportError:
@@ -13,21 +14,37 @@ import httpx
13
14
 
14
15
  from .client import Client
15
16
  from .constants import DEFAULT_URL
16
- from .schemas import Metric, Sport
17
+ from .schemas import Metric, Scope, Sport
17
18
  from .utils import format_sport
18
19
 
19
20
  class StreamlitAuth:
20
- def __init__(self, client_id=None, client_secret=None, scope=None, redirect_uri=None):
21
+ def __init__(
22
+ self,
23
+ client_id=None,
24
+ client_secret=None,
25
+ scopes: List[Union[str, Scope]]=None,
26
+ redirect_uri=None,
27
+ ):
21
28
  """
22
29
  Args:
23
30
  client_id: The client ID to use. If not provided, the SWEATSTACK_CLIENT_ID environment variable will be used.
24
31
  client_secret: The client secret to use. If not provided, the SWEATSTACK_CLIENT_SECRET environment variable will be used.
25
- scope: The scope to use. If not provided, the SWEATSTACK_SCOPE environment variable will be used.
32
+ scopes: The scopes to use. If not provided, the SWEATSTACK_SCOPES environment variable will be used. Defaults to data:read, profile.
26
33
  redirect_uri: The redirect URI to use. If not provided, the SWEATSTACK_REDIRECT_URI environment variable will be used.
27
34
  """
28
35
  self.client_id = client_id or os.environ.get("SWEATSTACK_CLIENT_ID")
29
36
  self.client_secret = client_secret or os.environ.get("SWEATSTACK_CLIENT_SECRET")
30
- self.scope = scope or os.environ.get("SWEATSTACK_SCOPE")
37
+
38
+ if scopes is not None:
39
+ self.scopes = [Scope(scope.strip().lower()) if isinstance(scope, str) else scope
40
+ for scope in scopes] if scopes else []
41
+ elif os.environ.get("SWEATSTACK_SCOPES"):
42
+ scopes = os.environ.get("SWEATSTACK_SCOPES").split(",")
43
+ self.scopes = [Scope(scope.strip().lower()) if isinstance(scope, str) else scope
44
+ for scope in scopes]
45
+ else:
46
+ self.scopes = [Scope.data_read, Scope.profile]
47
+
31
48
  self.redirect_uri = redirect_uri or os.environ.get("SWEATSTACK_REDIRECT_URI")
32
49
 
33
50
  self.api_key = st.session_state.get("sweatstack_api_key")
@@ -81,7 +98,7 @@ class StreamlitAuth:
81
98
  params = {
82
99
  "client_id": self.client_id,
83
100
  "redirect_uri": self.redirect_uri,
84
- "scope": "data:read",
101
+ "scope": ",".join([scope.value for scope in self.scopes]),
85
102
  "prompt": "none",
86
103
  }
87
104
  path = "/oauth/authorize"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sweatstack
3
- Version: 0.36.0
3
+ Version: 0.37.0
4
4
  Summary: The official Python client for SweatStack
5
5
  Author-email: Aart Goossens <aart@gssns.io>
6
6
  Requires-Python: >=3.9
@@ -6,12 +6,12 @@ sweatstack/ipython_init.py,sha256=zBGUlMFkdpLvsNpOpwrNaKRUpUZhzaICvH8ODJgMPcI,22
6
6
  sweatstack/jupyterlab_oauth2_startup.py,sha256=eZ6xi0Sa4hO4vUanimq0SqjduHtiywCURSDNWk_I-7s,1200
7
7
  sweatstack/openapi_schemas.py,sha256=rB_gdkob49AISTebZXmNjOOz3it28Y42_PEKcBF24c0,13576
8
8
  sweatstack/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
- sweatstack/schemas.py,sha256=RUbM70A4znSyEJojrvfB17894qd0sn0xhu0LhfbXaHw,152
10
- sweatstack/streamlit.py,sha256=QV_lPykNgcOR1cAO9F0B4hB_sax2IAMZGHOQLwG_0Rw,12368
9
+ sweatstack/schemas.py,sha256=zRxssFvsXmCTtLr69a7n_EHUUbfAG27w6cTr730ZeUY,159
10
+ sweatstack/streamlit.py,sha256=dtli4RpBiS8cH4GAQ9lDI_ZRDMLoU7GnTc676nLV_4A,13008
11
11
  sweatstack/sweatshell.py,sha256=MYLNcWbOdceqKJ3S0Pe8dwHXEeYsGJNjQoYUXpMTftA,333
12
12
  sweatstack/utils.py,sha256=WMY0THAfktzeDNH3kuwYNtVaoS1OQMaobONtGhpLI2E,2547
13
13
  sweatstack/Sweat Stack examples/Getting started.ipynb,sha256=k2hiSffWecoQ0VxjdpDcgFzBXDQiYEebhnAYlu8cgX8,6335204
14
- sweatstack-0.36.0.dist-info/METADATA,sha256=MU9jzkXLTmBSAKSk9EBVSks3MTg81xYz0Z89TQwOye8,779
15
- sweatstack-0.36.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
16
- sweatstack-0.36.0.dist-info/entry_points.txt,sha256=kCzOUQI3dqbTpEYqtgYDeiKFaqaA7BMlV6D24BMzCFU,208
17
- sweatstack-0.36.0.dist-info/RECORD,,
14
+ sweatstack-0.37.0.dist-info/METADATA,sha256=MQf29vXxKG9b22yMQvH9apE5uWwljU1RY0NQRVSuUng,779
15
+ sweatstack-0.37.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
16
+ sweatstack-0.37.0.dist-info/entry_points.txt,sha256=kCzOUQI3dqbTpEYqtgYDeiKFaqaA7BMlV6D24BMzCFU,208
17
+ sweatstack-0.37.0.dist-info/RECORD,,