Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

General Discussion

Alcibiades Montas
Alcibiades Montas
5,974 Points

Foursquare API: Unsupported Grant Type Error

Hey guys,

I am having issues getting my authorization token to connect to the Foursquare API.

My page is hosted here:

http://almontas.github.io/FourSquareJax/

However I keep on getting this error message:

{"error":"unsupported_grant_type"}

Any ideas as to what can be contributing to this error? See my code below (you can also see it on Github):

 $(document).ready(function() {
        var foursquareApi = {
                    clientId: "4B4T220TQF43NIUKJAQI1DNASEOI12NBTTUNZ5YOETDDQORF",
                    clientSecret: "YDBCTHJECBNMQVFWRC1GU5RFGGPHRY4Y1VGHSVD4PLMGRKNB",
                    redirectUrl : "http://almontas.github.io/FourSquareJax/"
                }



    if (access_token == null) {       
        $('.dashboardProfile').hide();   
        $('.dashboardInfo').hide(); 
        $('.dashboardConnect').show();   
        $('.connect').click(function() {   
            var url = "https://foursquare.com/oauth2/access_token";
            url += "?client_id="+foursquareApi.clientId;
            url += "&response_type=token";
            url += "&redirect_uri="+foursquareApi.redirectUrl;
            window.location = url;
        });
    }
    else {
        $('.dashboardProfile').show();   
        $('.dashboardInfo').show();
        $('.dashboardConnect').hide();
    }