Skip to content

Commit

Permalink
updated the token validator
Browse files Browse the repository at this point in the history
  • Loading branch information
mmohades committed Oct 23, 2020
1 parent a3858c0 commit 7862739
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 4 additions & 3 deletions venmo_api/utils/api_util.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from enum import Enum
from typing import Dict, List
from venmo_api import ArgumentMissingError, User
import re


def validate_access_token(access_token):
Expand All @@ -9,13 +10,13 @@ def validate_access_token(access_token):
:param access_token:
:return:
"""
token_re = r'^(Bearer)?(.+)$'
if not access_token:
return

if access_token[:6] != 'Bearer':
return f"Bearer {access_token}"
access_token = re.findall(token_re, access_token)[0][1].replace(' ', '')

return access_token
return f"Bearer {access_token}"


def deserialize(response: Dict, data_type, nested_response: List[str] = None):
Expand Down
1 change: 1 addition & 0 deletions venmo_api/venmo.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,5 @@ def log_out(access_token) -> bool:
:param access_token:
:return: <bool>
"""
access_token = validate_access_token(access_token=access_token)
return AuthenticationApi.log_out(access_token=access_token)

0 comments on commit 7862739

Please sign in to comment.