garrettdowd / splitwise_export

Export more data from Splitwise include receipts
6 stars 0 forks source link

How to get oauth_verifier? #2

Open ManuelBanza opened 3 years ago

ManuelBanza commented 3 years ago

Hi @garrettdowd Great project!

One question, how can I get my oauth_verifier?

In my app I only have the consumer key and Consumer secret

cheers

garrettdowd commented 3 years ago

If you are directly running the splitwise_export.py script then oauth is taken care of in the script.

If you are importing splitwise_export.py into your own script then you will need to run sObj = spwe.authorize() as detailed in the readme. sObj stores the oauth and allows you to make requests via the Splitwise API.

Oauth and requests to the Splitwise API are handled by the Splitwise Python SDK. If you have more specific oauth questions then it would be best to look there.

ManuelBanza commented 3 years ago

I did that but I get this message:

Captura de ecrã 2021-01-11, às 22 14 11
garrettdowd commented 3 years ago

That is expected behavior on first time authorization. However, it looks like you are running this script in a Jupyter notebook or something similar?

The script uses Python's standard input() function to accept the consumer key/secret. Jupyter might be having a problem with this.

If comfortable, you can take a look at the authorize() function in the splitwise_export.py script which is just a wrapper for the aforementioned Splitwise Python SDK. You could run the code contained within after manually substituting in your key/secret/oauth_verifier and it should work.

ManuelBanza commented 3 years ago

Hi @garrettdowd thanks for the help.

I was using Jupyter but now switch to visual code to run the script. As you can see I changed the consumer_key and consumer secret. Then I runned the script and a message in terminal appeared say in: "No pre-existing authorization found. Creating new auth" followed by a code.

I took that code and replaced it in the oauth_verifier.

But I get an error

Captura de ecrã 2021-01-12, às 17 38 23
garrettdowd commented 3 years ago

No worries. Python's input() is a function that obtains user input via the terminal (interpreter). For the above method to work you will need to directly set auth['consumer_key']=your_consumer_key

I am not too familiar with VS Code's Python interpreter, but you may be able to run the original script (no key/secret substitution) with a properly defined environment. I think the input() function should work via VS Code's terminal.

I would also recommend trying to run the script using Anaconda Prompt (Miniconda).

ManuelBanza commented 3 years ago

I get this erro now:

raise SplitwiseUnauthorizedException("Please check your token or consumer id and secret", response=response) splitwise.exception.SplitwiseUnauthorizedException: Your oauth token could be expired or check your consumer id and secret

However I double check the consumer and secret and they are correct. Even why I run in the terminal I get this error

ManuelBanza commented 3 years ago

I still cannot understand where can I get oath_verifier.

kizzard commented 2 years ago

@ManuelBanza I ran into this problem as well but I solved it. When registering the app with Splitwise, you need to enter a "Callback URL" (even though it says this is optional). You can put anything here. I put my personal website. The URL doesn't even have to exist. But after you click the Authorize button on the Splitwise website, it will redirect to the URL you provided, and it will add 2 URL Query string parameters, one if which is the infamous "oauth_verifier". You can copy this and complete the credentials setup.

JVaxx1 commented 1 year ago

This works! Thanks so much kizzard.