Balance fetching stopped working
gseastream opened this issue · comments
I've been using a customization of this venmo api for a while, because I only wanted my application to be able to fetch the balance for a single account (over and over on a scheduled task). I've done so with the following code:
if not venmo.auth.configure():
print("Venmo configuration failed.")
return
access_token = venmo.auth.get_access_token()
data = {"access_token": access_token}
response = requests.get("https://api.venmo.com/v1/me", json=data)
try:
return float(response.json()["data"]["balance"])
except KeyError:
print("Access token has expired. Returning None.")
return None
However I just realized this stopped working. Now the response of the GET is a 403 Forbidden, saying the request could not be satisfied, bad request. The documentation online for the api is pretty sparse so I couldn't find anything, but I was wondering if you had any insights on this issue?
I solved the issue, or at least found a workaround. If I "manually" format the url such as
https://api.venmo.com/v1/me?access_token=TOKEN_HERE
or even using v5
https://venmo.com/api/v5/me?access_token=TOKEN_HERE
Then it works fine. I don't know what changed, be it the venmo api or the requests package. Anyway, closing this now.
This issue is similar in spirit to #53. The shared cause is that Venmo is slowly moving APIs behind authentication (which is a good thing!).
The fix for #53 is similar to your workaround, which is to add authentication to the request: https://github.com/zackhsi/venmo/pull/54/files#diff-3584b91c58a32b781a297ca5b74d1001R31.
So when I switched the json keyword to params in the get method for sending my data dict, that worked. My understanding is the json puts the provided dict in the body of the request, while params puts it in the query url. Is there a reason venmo changed to require the token be in the query?
They can decide to modify their API however they like :)