anaplan-sdk 0.4.0a3__py3-none-any.whl → 0.4.1__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.
@@ -56,6 +56,7 @@ class AsyncClient(_AsyncBaseClient):
56
56
  redirect_uri: str | None = None,
57
57
  refresh_token: str | None = None,
58
58
  oauth2_scope: str = "openid profile email offline_access",
59
+ on_auth_code: Callable[[str], str] | None = None,
59
60
  on_token_refresh: Callable[[dict[str, str]], None] | None = None,
60
61
  timeout: float | httpx.Timeout = 30,
61
62
  retry_count: int = 2,
@@ -91,6 +92,9 @@ class AsyncClient(_AsyncBaseClient):
91
92
  :param refresh_token: If you have a valid refresh token, you can pass it to skip the
92
93
  interactive authentication code step.
93
94
  :param oauth2_scope: The scope of the Oauth2 token, if you want to narrow it.
95
+ :param on_auth_code: A callback that takes the redirect URI as a single argument and must
96
+ return the entire response URI. This will substitute the interactive
97
+ authentication code step in the terminal.
94
98
  :param on_token_refresh: A callback function that is called whenever the token is refreshed.
95
99
  With this you can for example securely store the token in your
96
100
  application or on your server for later reuse. The function
@@ -124,6 +128,7 @@ class AsyncClient(_AsyncBaseClient):
124
128
  redirect_uri=redirect_uri,
125
129
  refresh_token=refresh_token,
126
130
  oauth2_scope=oauth2_scope,
131
+ on_auth_code=on_auth_code,
127
132
  on_token_refresh=on_token_refresh,
128
133
  )
129
134
  ),
anaplan_sdk/_auth.py CHANGED
@@ -144,6 +144,7 @@ class AnaplanOauth2AuthCodeAuth(_AnaplanAuth):
144
144
  redirect_uri: str,
145
145
  refresh_token: str | None = None,
146
146
  scope: str = "openid profile email offline_access",
147
+ on_auth_code: Callable[[str], str] | None = None,
147
148
  on_token_refresh: Callable[[dict[str, str]], None] | None = None,
148
149
  ):
149
150
  try:
@@ -163,6 +164,7 @@ class AnaplanOauth2AuthCodeAuth(_AnaplanAuth):
163
164
  self._refresh_token = refresh_token
164
165
  self._scope = scope
165
166
  self._id_token = None
167
+ self._on_auth_code = on_auth_code
166
168
  self._on_token_refresh = on_token_refresh
167
169
  if not refresh_token:
168
170
  self.__auth_code_flow()
@@ -195,13 +197,17 @@ class AnaplanOauth2AuthCodeAuth(_AnaplanAuth):
195
197
  try:
196
198
  logger.info("Creating Authentication Token with OAuth2 Authorization Code Flow.")
197
199
  url, _, _ = self._oauth.prepare_authorization_request(
198
- "https://us1a.app.anaplan.com/auth/authorize",
200
+ "https://us1a.app.anaplan.com/auth/prelogin",
199
201
  redirect_url=self._redirect_uri,
200
202
  scope=self._scope,
201
203
  )
202
- authorization_response = input(
203
- f"Please go to {url} and authorize the app.\n"
204
- "Then paste the entire redirect URL here: "
204
+ authorization_response = (
205
+ self._on_auth_code(url)
206
+ if self._on_auth_code
207
+ else input(
208
+ f"Please go to {url} and authorize the app.\n"
209
+ "Then paste the entire redirect URL here: "
210
+ )
205
211
  )
206
212
  url, headers, body = self._oauth.prepare_token_request(
207
213
  token_url=self._token_url,
@@ -211,7 +217,7 @@ class AnaplanOauth2AuthCodeAuth(_AnaplanAuth):
211
217
  )
212
218
  self._parse_auth_response(httpx.post(url=url, headers=headers, content=body))
213
219
  except (httpx.HTTPError, ValueError, TypeError, OAuth2Error) as error:
214
- raise AnaplanException("Error during OAuth2 authorization flow.") from error
220
+ raise InvalidCredentialsException("Error during OAuth2 authorization flow.") from error
215
221
 
216
222
 
217
223
  def create_auth(
@@ -225,6 +231,7 @@ def create_auth(
225
231
  redirect_uri: str | None = None,
226
232
  refresh_token: str | None = None,
227
233
  oauth2_scope: str = "openid profile email offline_access",
234
+ on_auth_code: Callable[[str], str] | None = None,
228
235
  on_token_refresh: Callable[[dict[str, str]], None] | None = None,
229
236
  ) -> _AnaplanAuth:
230
237
  if certificate and private_key:
@@ -238,6 +245,7 @@ def create_auth(
238
245
  redirect_uri=redirect_uri,
239
246
  refresh_token=refresh_token,
240
247
  scope=oauth2_scope,
248
+ on_auth_code=on_auth_code,
241
249
  on_token_refresh=on_token_refresh,
242
250
  )
243
251
  raise ValueError(
@@ -58,6 +58,7 @@ class Client(_BaseClient):
58
58
  redirect_uri: str | None = None,
59
59
  refresh_token: str | None = None,
60
60
  oauth2_scope: str = "openid profile email offline_access",
61
+ on_auth_code: Callable[[str], str] | None = None,
61
62
  on_token_refresh: Callable[[dict[str, str]], None] | None = None,
62
63
  timeout: float | httpx.Timeout = 30,
63
64
  retry_count: int = 2,
@@ -94,6 +95,9 @@ class Client(_BaseClient):
94
95
  :param refresh_token: If you have a valid refresh token, you can pass it to skip the
95
96
  interactive authentication code step.
96
97
  :param oauth2_scope: The scope of the Oauth2 token, if you want to narrow it.
98
+ :param on_auth_code: A callback that takes the redirect URI as a single argument and must
99
+ return the entire response URI. This will substitute the interactive
100
+ authentication code step in the terminal.
97
101
  :param on_token_refresh: A callback function that is called whenever the token is refreshed.
98
102
  With this you can for example securely store the token in your
99
103
  application or on your server for later reuse. The function
@@ -130,6 +134,7 @@ class Client(_BaseClient):
130
134
  redirect_uri=redirect_uri,
131
135
  refresh_token=refresh_token,
132
136
  oauth2_scope=oauth2_scope,
137
+ on_auth_code=on_auth_code,
133
138
  on_token_refresh=on_token_refresh,
134
139
  )
135
140
  ),
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: anaplan-sdk
3
- Version: 0.4.0a3
4
- Summary: Provides pythonic access to the Anaplan API
3
+ Version: 0.4.1
4
+ Summary: Streamlined Python Interface for Anaplan
5
5
  Project-URL: Homepage, https://vinzenzklass.github.io/anaplan-sdk/
6
6
  Project-URL: Repository, https://github.com/VinzenzKlass/anaplan-sdk
7
7
  Project-URL: Documentation, https://vinzenzklass.github.io/anaplan-sdk/
@@ -13,7 +13,7 @@ Requires-Python: >=3.10.4
13
13
  Requires-Dist: httpx<1.0.0,>=0.27.0
14
14
  Requires-Dist: pydantic<3.0.0,>=2.7.2
15
15
  Provides-Extra: cert
16
- Requires-Dist: cryptography<45.0.0,>=42.0.7; extra == 'cert'
16
+ Requires-Dist: cryptography<46.0.0,>=42.0.7; extra == 'cert'
17
17
  Provides-Extra: oauth
18
18
  Requires-Dist: oauthlib<4.0.0,>=3.0.0; extra == 'oauth'
19
19
  Description-Content-Type: text/markdown
@@ -1,18 +1,18 @@
1
1
  anaplan_sdk/__init__.py,sha256=5fr-SZSsH6f3vkRUTDoK6xdAN31cCpe9Mwz2VNu47Uw,134
2
- anaplan_sdk/_auth.py,sha256=wqlyrZwaJSEXW5J2-GV4UIw7KxDkfQ-loWdePVy2lWg,10231
2
+ anaplan_sdk/_auth.py,sha256=LjPKGoM7qqiFmr9qC4_ZnV9sTHPbvhrnf6iSq_w1tNI,10569
3
3
  anaplan_sdk/_base.py,sha256=9CdLshORWsLixOyoFa3A0Bka5lhLwlZrQI5sEdBcGFI,12298
4
4
  anaplan_sdk/exceptions.py,sha256=ALkA9fBF0NQ7dufFxV6AivjmHyuJk9DOQ9jtJV2n7f0,1809
5
5
  anaplan_sdk/_async_clients/__init__.py,sha256=pZXgMMg4S9Aj_pxQCaSiPuNG-sePVGBtNJ0133VjqW4,364
6
6
  anaplan_sdk/_async_clients/_alm.py,sha256=O1_r-O1tNDq7vXRwE2UEFE5S2bPmPh4IAQPQ8bmZfQE,3297
7
7
  anaplan_sdk/_async_clients/_audit.py,sha256=a92RY0B3bWxp2CCAWjzqKfvBjG1LJGlai0Hn5qmwgF8,2312
8
- anaplan_sdk/_async_clients/_bulk.py,sha256=pvx0ux5tAAtCsNJrJorC_SDRxvDUSWu5aKPolE1_nuo,25297
8
+ anaplan_sdk/_async_clients/_bulk.py,sha256=YLttQd9oVHrvafXZ_J0QD8EQ3QCtmcT9YRZQ8_X71AI,25674
9
9
  anaplan_sdk/_async_clients/_cloud_works.py,sha256=KPX9W55SF6h8fJd4Rx-HLq6eaRA-Vo3rFu343UiiaGQ,16642
10
10
  anaplan_sdk/_async_clients/_cw_flow.py,sha256=ZTNAbKDwb59Wg3u68hbtt1kpd-LNz9K0sftT-gvYzJQ,3651
11
11
  anaplan_sdk/_async_clients/_transactional.py,sha256=Mvr7OyBPjQRpBtzkJNfRzV4aNCzUiaYmm0zQubo62Wo,8035
12
12
  anaplan_sdk/_clients/__init__.py,sha256=FsbwvZC1FHrxuRXwbPxUzbhz_lO1DpXIxEOjx6-3QuA,219
13
13
  anaplan_sdk/_clients/_alm.py,sha256=UAdQxgHfax-VquC0YtbqrRBku2Rn35tVgwJdxYFScps,3202
14
14
  anaplan_sdk/_clients/_audit.py,sha256=xQQiwWIb4QQefolPvxNwBFE-pkRzzi8fYPyewjF63lc,2181
15
- anaplan_sdk/_clients/_bulk.py,sha256=oSXhcIZoVtRnDelhPQVKd_zE-5M9qRnXc7GKBwH-Fhw,25105
15
+ anaplan_sdk/_clients/_bulk.py,sha256=TVinTtTYnlcoTrOX0ldpW11qui5rSUXm_PE1L7JgST8,25466
16
16
  anaplan_sdk/_clients/_cloud_works.py,sha256=KAMnLoeMJ2iwMXlDSbKynCE57BtkCfOgM5O8wT1kkSs,16291
17
17
  anaplan_sdk/_clients/_cw_flow.py,sha256=5IFWFT-qbyGvaSOOtaFOjHnOlyYbj4Rj3xiavfTlm8c,3527
18
18
  anaplan_sdk/_clients/_transactional.py,sha256=YUVbA54uhMloQcahwMtmZO3YooO6qQzwZN3ZRSu_z_c,7976
@@ -23,7 +23,7 @@ anaplan_sdk/models/_bulk.py,sha256=dHP3kMvsKONCZS6mHB271-wp2S4P3rM874Ita8TzABU,8
23
23
  anaplan_sdk/models/_transactional.py,sha256=_0UbVR9D5QABI29yloYrJTSgL-K0EU7PzPeJu5LdhnY,4854
24
24
  anaplan_sdk/models/cloud_works.py,sha256=nfn_LHPR-KmW7Tpvz-5qNCzmR8SYgvsVV-lx5iDlyqI,19425
25
25
  anaplan_sdk/models/flows.py,sha256=SuLgNj5-2SeE3U1i8iY8cq2IkjuUgd_3M1n2ENructk,3625
26
- anaplan_sdk-0.4.0a3.dist-info/METADATA,sha256=aq6VvmcjhtVznA7cCfekL44FB3oULdLxn4EnVoUy_SU,3548
27
- anaplan_sdk-0.4.0a3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
28
- anaplan_sdk-0.4.0a3.dist-info/licenses/LICENSE,sha256=HrhfyXIkWY2tGFK11kg7vPCqhgh5DcxleloqdhrpyMY,11558
29
- anaplan_sdk-0.4.0a3.dist-info/RECORD,,
26
+ anaplan_sdk-0.4.1.dist-info/METADATA,sha256=BBxu0ztPLPPxIJtueo3P3cfs1webd9Fxu60hFdHi0p8,3543
27
+ anaplan_sdk-0.4.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
28
+ anaplan_sdk-0.4.1.dist-info/licenses/LICENSE,sha256=HrhfyXIkWY2tGFK11kg7vPCqhgh5DcxleloqdhrpyMY,11558
29
+ anaplan_sdk-0.4.1.dist-info/RECORD,,