z22
z22

Reputation: 10083

Foursquare invalid grant error

i am new to foursquare and i wish to have autofill textbox by foursquare api. For this i referred to https://developer.foursquare.com/overview/auth and have registered my app with foursquare. When I write

https://foursquare.com/oauth2/access_token
    ?client_id=YOUR_CLIENT_ID
    &client_secret=YOUR_CLIENT_SECRET
    &grant_type=authorization_code
    &redirect_uri=YOUR_REGISTERED_REDIRECT_URI
    &code=CODE

in browser url (all parameters replaced), i get the following error:

 {

    "error": "invalid_grant"

}

How do i solve this? How do i implement autofill textbox?

Upvotes: 2

Views: 852

Answers (2)

ffflabs
ffflabs

Reputation: 17481

Extending pfhayes answer: CODE is not a constant. Your are supposed to actually replace it with a real code.

It can get confusing, because at some point during the auth flow, there are constants such as code and access_token that should be taken exactly ad in the example.

Upvotes: 1

pfhayes
pfhayes

Reputation: 3927

The code you supply must be the code returned by a successful user authorization, as seen here: https://developer.foursquare.com/overview/auth. When a user authorizes your app with foursquare, they will be redirected to your page with a code HTTP parameter. This code will be the code you exchange for a valid access token.

Upvotes: 0

Related Questions