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

Ask A Question

Stats

  • Questions 507k
  • Answers 507k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Here is what I had to do (using the example… May 16, 2026 at 4:05 pm
  • Editorial Team
    Editorial Team added an answer Here are a few if statements and how they translate… May 16, 2026 at 4:05 pm
  • Editorial Team
    Editorial Team added an answer Visual C/C++ has a #pragma that allows you to 'insert'… May 16, 2026 at 4:05 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I was curious if anyone had any suggestions on a Java library that provides
Has anyone tried to use gold instead of ld ? gold promises to be
I have an application written in C++ (makes heavy use of templates) that I
I wonder if there are any suggestions for declarative GUI programming in Java. (I
I'm trying to have a grid that has items that have a custom layout/feel.
Note: I do NOT want to use any framework. The goal is just to
I was reading up some things about how to design a library or API
I am starting on an enhancement to an existing Java applet where I let
I'll come up with any excuse to get a chance to write my first
I'm writing some code that uses a Tree (a regular tree that can have

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.