Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed 'response_type' to 'token' #18

Closed
wants to merge 1 commit into from
Closed

Changed 'response_type' to 'token' #18

wants to merge 1 commit into from

Conversation

jasminegao
Copy link

'&response_type=code' no longer works for the auth_uri, foursquare's oauth docs state to use '&response_type=token' instead (https://developer.foursquare.com/overview/auth)

'&response_type=code' no longer, foursquare's oauth docs state to use '&response_type=token' instead (https://developer.foursquare.com/overview/auth)
@mLewisLogic
Copy link
Owner

Where in the docs does it say that 'code' is deprecated? It seems like they're just two different flows?

@jasminegao
Copy link
Author

For some reason, in my use case, the 'code' flow returned an access token that was classified as invalid/revoked when entered into the client, which made sense after I checked my connected apps and saw the one I just authenticated wasn't listed (even though authentication was successful). For reference, the auth_uri used for this was: https://foursquare.com/oauth2/authenticate?redirect_uri=https%3A%2F%2Ffoursquare.com%2F&response_type=code&client_id=XSW0MJM4OFZOYAWLLLXRXFKNJ2JPRLD0C3Z3YJBBHRO00OSA

The above issue was solved when I made another test app using the 'token' flow (with the only difference being the response_type): https://foursquare.com/oauth2/authenticate?redirect_uri=https%3A%2F%2Ffoursquare.com%2F&response_type=token&client_id=OWZIQVDO4TO3FLF1DGJNAYAS2MBKB5EXYLDFSXNHZIVKAZ1O

@mLewisLogic
Copy link
Owner

You made the call to https://foursquare.com/oauth2/access_token after you got your 'code' ?

The code flow doesn't give you a valid token back on the first response.

@jasminegao
Copy link
Author

I used this flow to grab and set the token, which returned the invalid token error:

client = foursquare.Foursquare(client_id='[omitted]', client_secret='[omitted]', redirect_uri='https://foursquare.com/')
auth_uri = client.oauth.auth_url()
print 'Visit this URL in your browser: ' + auth_uri

access_token = raw_input('Copy the code at the end of your browser url: ')
client.set_access_token(access_token)

@mLewisLogic
Copy link
Owner

You missed the second part of the token dance:

# Interrogate foursquare's servers to get the user's access_token
access_token = client.oauth.get_token('XX_CODE_RETURNED_IN_REDIRECT_XX')

You need to send the returned code into Foursquare in order to get a valid token.

@mLewisLogic mLewisLogic closed this Apr 6, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants