Skip to content

Commit

Permalink
For testing pushing a cut
Browse files Browse the repository at this point in the history
  • Loading branch information
jeeftor committed Jan 19, 2024
1 parent 633f0a4 commit 93cee42
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "simplefin4py"
version = "0.0.9"
version = "0.0.10"
description = ""
authors = ["Jeef <[email protected]>"]
readme = "README.md"
Expand Down
36 changes: 26 additions & 10 deletions simplefin4py/simplefin.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,32 @@
class SimpleFin:
"""SimpleFin Class."""

# proxy: str | None
@classmethod
def decode_claim_token(cls, token_string: str) -> str:
"""Decode a claim token string - or throws an error."""
try:
claim_url = base64.b64decode(token_string).decode("utf-8")
except binascii.Error as err:
raise SimpleFinInvalidClaimTokenError from err
return claim_url

@classmethod
def decode_access_url(cls, access_url: str) -> tuple[str, str, str]:
"""Decode an access URL string - or throws an error."""
try:
scheme, rest = access_url.split("//", 1)
auth, rest = rest.split("@", 1)
except ValueError as err:
raise SimpleFinInvalidAccountURLError from err

return scheme, rest, auth

@classmethod
async def claim_setup_token(
cls, setup_token: str, verify_ssl: bool = True, proxy: str | None = None
) -> str:
"""Exchanges a 1-time setup token for an access token."""
try:
claim_url = base64.b64decode(setup_token).decode("utf-8")
except binascii.Error as err:
raise SimpleFinInvalidClaimTokenError from err
claim_url = cls.decode_claim_token(setup_token)

auth = BasicAuth(
login="", password=""
Expand Down Expand Up @@ -65,11 +80,12 @@ def __init__(
self.access_url = access_url
self.verify_ssl = verify_ssl

scheme, rest = access_url.split("//", 1)
try:
self.auth, rest = rest.split("@", 1)
except ValueError as err:
raise SimpleFinInvalidAccountURLError from err
scheme, rest, self.auth = self.decode_access_url(access_url)
# try:
# scheme, rest = access_url.split("//", 1)
# self.auth, rest = rest.split("@", 1)
# except ValueError as err:
# raise SimpleFinInvalidAccountURLError from err
self.url = scheme + "//" + rest + "/accounts"
self.username, self.password = self.auth.split(":", 1)
self.proxy: str | None = proxy
Expand Down

0 comments on commit 93cee42

Please sign in to comment.