Did you know? Programmers convert coffee to code.

If you like my articles, sponsor me a coffee.

At the other end of the link I post some results of my other hobbies, like playing bass. It is worth checking it out ;)

Getting a Foursquare authentication token

During my vacation I played with the Foursquare API and have written some scripts to extract information. And during this I shut down the exploring API for some time because I used their authentication token and exceeded the limit of 5000 requests.

And because of this I thought about writing a simple method how you can get an own authentication token for your testing purposes to save the available exploration API for users who just want to look at the provided information.

1. Create an app

The first step is to create an application.

I won’t go into deeper detail because if you are reading this article you are already familiar with the API and the documentation of it so you know how to register a developer account and create an app.

The important thing however is to add a Redirect URI which does not work. Such an URI could be for example


I used this URI actually for my token generation.

2. Get the token

This is the “tricky” part however if you have set-up the redirect URI right then you won’t find it hard to get things rolling.

If you look at the authentication documentation you will see that there are some ways how to get a token. I used the not preferred way of “Token flow”.

You can see to have the token you only need to redirect the user to a specific URL and then if he/she accepts the terms and enables your application the browser will be redirected to the given URI if it is registered with your app.

And this is what I used to solve my problem. I opened up my browser and entered the following URL and hit enter:


And after I accepted the terms I got a token in the form that the browser was redirected to the following URL:


And this was it because the browser could not display the website and I have seen the access token and could copy it to use it inside my application.

With this access token I omit myself and you from the trouble that the free-for-all API is not available. Naturally this can happen if 5000 developers try out a qurey simultaneously.


“MY_APPS_CLIENT_ID” and “THE_ACCESS_TOKEN” are just examples where I replaced my secret information to save myself from the trouble if some of you would try to access the API with my app and cause some harm.


Some options seem easy to use but remember that great power comes with great responsibility. So use your power to find solutions to your problems and do not harm others.

Share the knowledge!

Senior developer, consultant, author, mentor, apprentice. I love to share my knowledge and insights what I achieve through my daily work which is not trivial -- at least not for me.

Click Here to Leave a Comment Below

%d bloggers like this: