sscheetz / etsy-python2

Python access to the Etsy API
http://developer.etsy.com
GNU General Public License v3.0
32 stars 18 forks source link

OAuth #3

Closed jacob085 closed 4 years ago

jacob085 commented 4 years ago

Hi there. Thanks for your work, very helpful I am learning python (very very basic skills). I try to use the OAuth Helper to get the token Seems like everything works good, but once i allow the app to access my data i am not redirect to the page for the verification code... so i can't terminate the OAuth process.

do you have any suggestions?

thanks v.

sscheetz commented 4 years ago

What happens when you tell etsy you approve access? Do you get redirected to a 404 page or something like that? If so, that is happening because are you passing a callback_uri to get_request_url_and_token_secret that doesnt exist (your webserver isn't exposing the url as an endpoint).

Unfortunately this library doesn't support manually inputting the verification code at this time. Generally, applications will pass a url for the callback_uri that is owned by their webserver and when the user clicks approve on Etsy's page, Etsy then redirects the user back to your app via the callback_url. You are probably redirecting to a url for and endpoint that currently doesnt exist.

I can add a quick enhancement this weekend that lets you manually enter the callback_uri, but if you just want your oauth tokens to start making requests you can work around this with something like


    auth_callback_url = 'https://fakecallback.com'
    permission_scopes = ['transactions_r', 'listings_r']
    login_url, temp_oauth_token_secret = EtsyOAuthHelper.get_request_url_and_token_secret(api_key, shared_secret, permission_scopes, auth_callback_url)
    print(login_url)
    # manually navigate to the login_url and tell etsy you approve
    # get redirect to fakecallback.com and copy and paste the url into the console
    # the next line of code will parse the url you pasted and get the verification code out of it
    oauth_token, oauth_token_secret = EtsyOAuthHelper.get_oauth_token(api_key, shared_secret, temp_oauth_token_secret, input('paste: '))
    print(oauth_token) # your access_token
    print(oauth_token_secret) # your access_token_secret
sscheetz commented 4 years ago

I added a method that allows you to manually input the verification code instead of using a callback url so update your package to version 0.6.0 and refer to "Obtaining Etsy OAuthCredentials" in the readme.

Specifically if you want to be redirected to the page showing the verification code, don't pass a callback_url

e.g. login_url, temp_oauth_token_secret = EtsyOAuthHelper.get_request_url_and_token_secret(api_key, shared_secret, permission_scopes)

but there are some other things you need to do to finish the process so refer to the readme.

jacob085 commented 4 years ago

Hi Sean

Thanks so much i will try this night

thanks again

v.

On 19 May 2020, at 11:39, Sean Scheetz notifications@github.com wrote:

Closed #3 https://github.com/sscheetz/etsy-python2/issues/3.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/sscheetz/etsy-python2/issues/3#event-3351208343, or unsubscribe https://github.com/notifications/unsubscribe-auth/APSB32JCQWYOLAL23H5AD23RSJOUTANCNFSM4M7SCEGQ.

jacob085 commented 4 years ago

It works!!! thanks a lot!!

v.

On 21 May 2020, at 19:26, vincenzo lullo jacob085@gmail.com wrote:

Hi Sean

Thanks so much i will try this night

thanks again

v.

On 19 May 2020, at 11:39, Sean Scheetz <notifications@github.com mailto:notifications@github.com> wrote:

Closed #3 https://github.com/sscheetz/etsy-python2/issues/3.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/sscheetz/etsy-python2/issues/3#event-3351208343, or unsubscribe https://github.com/notifications/unsubscribe-auth/APSB32JCQWYOLAL23H5AD23RSJOUTANCNFSM4M7SCEGQ.