Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh-XT committed Jun 13, 2024
1 parent becb047 commit 8096f29
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
14 changes: 11 additions & 3 deletions sso/fitbit.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ def __init__(
self.user_info = self.get_user_info()

def get_new_token(self):
decoded_token = base64.b64encode(f"{self.client_id}:{self.client_secret}".encode()).decode()
decoded_token = base64.b64encode(
f"{self.client_id}:{self.client_secret}".encode()
).decode()
response = requests.post(
"https://api.fitbit.com/oauth2/token",
headers={
Expand Down Expand Up @@ -81,7 +83,9 @@ def get_user_info(self):
data = response.json()
first_name = data["user"]["firstName"]
last_name = data["user"]["lastName"]
email = data["user"]["fullName"] # Note: Fitbit may not provide email directly
email = data["user"][
"fullName"
] # Note: Fitbit may not provide email directly
return {
"email": email,
"first_name": first_name,
Expand Down Expand Up @@ -114,13 +118,17 @@ def get_activities(self):
)
return response.json()


def fitbit_sso(code, redirect_uri=None) -> FitbitSSO:
if not redirect_uri:
redirect_uri = getenv("MAGIC_LINK_URL")
token = base64.b64encode(
f"{getenv('FITBIT_CLIENT_ID')}:{getenv('FITBIT_CLIENT_SECRET')}".encode()
).decode()
response = requests.post(
"https://api.fitbit.com/oauth2/token",
headers={
"Authorization": f"Basic {base64.b64encode(f'{getenv('FITBIT_CLIENT_ID')}:{getenv('FITBIT_CLIENT_SECRET')}'.encode()).decode()}",
"Authorization": f"Basic {token}",
"Content-Type": "application/x-www-form-urlencoded",
},
data={
Expand Down
12 changes: 9 additions & 3 deletions sso/paypal.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
- openid
"""


class PayPalSSO:
def __init__(
self,
Expand All @@ -36,7 +37,9 @@ def __init__(
self.user_info = self.get_user_info()

def get_new_token(self):
token = base64.b64encode(f"{self.client_id}:{self.client_secret}".encode()).decode()
token = base64.b64encode(
f"{self.client_id}:{self.client_secret}".encode()
).decode()
response = requests.post(
"https://api.paypal.com/v1/oauth2/token",
headers={
Expand Down Expand Up @@ -83,7 +86,7 @@ def get_user_info(self):
detail=f"Error getting user info from PayPal: {str(e)}",
)

def send_payment(self, recipient_email, amount, currency='USD'):
def send_payment(self, recipient_email, amount, currency="USD"):
"""This is an extra method for sending payment in PayPal."""
payment_data = {
"sender_batch_header": {
Expand Down Expand Up @@ -127,10 +130,13 @@ def send_payment(self, recipient_email, amount, currency='USD'):
def paypal_sso(code, redirect_uri=None) -> PayPalSSO:
if not redirect_uri:
redirect_uri = getenv("MAGIC_LINK_URL")
token = base64.b64encode(
f"{getenv('PAYPAL_CLIENT_ID')}:{getenv('PAYPAL_CLIENT_SECRET')}".encode()
).decode()
response = requests.post(
"https://api.paypal.com/v1/oauth2/token",
headers={
"Authorization": f"Basic {base64.b64encode(f'{getenv('PAYPAL_CLIENT_ID')}:{getenv('PAYPAL_CLIENT_SECRET')}'.encode()).decode()}",
"Authorization": f"Basic {token}",
"Content-Type": "application/x-www-form-urlencoded",
},
data={
Expand Down

0 comments on commit 8096f29

Please sign in to comment.