Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 924995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:27:02+00:00 2026-05-15T19:27:02+00:00

Has anyone use any good Java API for four square oauth ? I am

  • 0

Has anyone use any good Java API for four square oauth ? I am looking for something that is thread safe ?

Cheers,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T19:27:03+00:00Added an answer on May 15, 2026 at 7:27 pm

    I started by using foursquare4j, but was unable to get it to successfully retrieve an access token, which is the final step needed before calling signing calls to the Foursquare API.
    So I switched to using signpost to get through the authentication bit and get an access token and secret, and then used foursquare4j as it encapsulates the API as a very nice object model.
    I don’t know if signpost or foursquare4j are inherently thread safe – you could ask that question in their forums.
    Below is a flatten version of the code I am using to authentication my App.
    I’m using the Play framework – authorize() receives the initial request for authentication, and oauth() is where foursquare redirects to once the user has allowed access.

    public class Foursquare extends Controller {
    
        static final String FOURSQUARE_OAUTH_REQUEST_TOKEN = "http://foursquare.com/oauth/request_token";
        static final String FOURSQUARE_OAUTH_ACCESS_TOKEN = "http://foursquare.com/oauth/access_token";
        static final String FOURSQUARE_OAUTH_AUTHORIZE = "http://foursquare.com/oauth/authorize";
        static final String CONSUMER_KEY = "N4FKW2GFLMU1UGR3DDQYE4IGJQRGID1JFXYPJS3XFLZN3EU6";
        static final String CONSUMER_SECRET = "DDGHBF25J3RJDD4N4QC2CMRF8YMA1CG94OGFRPTY4RQNLMVH";
    
    
        // Handle Request for foursquare Authorization
        public static void authorize() throws OAuthMessageSignerException, OAuthNotAuthorizedException, OAuthExpectationFailedException, OAuthCommunicationException {
    
            oauth.signpost.OAuthProvider provider = new DefaultOAuthProvider(FOURSQUARE_OAUTH_REQUEST_TOKEN, FOURSQUARE_OAUTH_ACCESS_TOKEN,FOURSQUARE_OAUTH_AUTHORIZE);
            oauth.signpost.OAuthConsumer consumer = new DefaultOAuthConsumer(CONSUMER_KEY,CONSUMER_SECRET);
            String authURL;
    
            authURL = provider.retrieveRequestToken(consumer,"");
    
            String tokenSecret = consumer.getTokenSecret();
            session.put("secret", tokenSecret);
            redirect(authURL);
        }
    
        // Handle call back from foursquare after user Accepts
        public static void oauth() throws IOException, OAuthMessageSignerException, OAuthNotAuthorizedException, OAuthExpectationFailedException, OAuthCommunicationException {
    
            oauth.signpost.OAuthProvider provider = new DefaultOAuthProvider(FOURSQUARE_OAUTH_REQUEST_TOKEN, FOURSQUARE_OAUTH_ACCESS_TOKEN,FOURSQUARE_OAUTH_AUTHORIZE);
            oauth.signpost.OAuthConsumer consumer = new DefaultOAuthConsumer(CONSUMER_KEY,CONSUMER_SECRET);
            String secret = session.get("secret");
            String pinCode = params.get("oauth_token");
            consumer.setTokenWithSecret(pinCode, secret);
            provider.retrieveAccessToken(consumer, pinCode);
    
            // Get the access token and secret
            String token = consumer.getToken();
            String tokenSecret = consumer.getTokenSecret();
    
            // Set foursquare4j Credentials
            foursquare4j.type.Credentials credentials = new Credentials();
            credentials.setTokenSecret(tokenSecret);
            credentials.setAccessToken(token);
    
            foursquare4j.oauth.OAuthConsumer newConsumer = new OAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET);
    
            foursquare4j.oauth.FoursquareOAuthImpl fs = new FoursquareOAuthImpl(newConsumer, credentials);
    
            try {
                // Get last 50 checkins
                Checkins checkins = fs.history("50", "");
    
                render(checkins);
            } catch (FoursquareException e) {
                e.printStackTrace();
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Anyone have any good tips on handling differences in web.config settings between environments? I've
I'm trying to have a grid that has items that have a custom layout/feel.
So, very soon, I will be part of a migration that will move a
I am reading the book Patterns of enterprise application architecture . While going through
I know the differences between ASP and ASP.NET generally, as I am new to
I tried googling and searching on stack but I didn't find anything :-( (
I'm revising my question from a few days ago. Rewrote my query. Can someone
A recent release of Fluent Nhibernate (1.1) now supports stored procedures. I was wondering
I would like to develop for Windows Phone 7 but the lack of database
My enterprise is about to start a somewhat complex project in which we will

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.