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 8473797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T17:27:05+00:00 2026-06-10T17:27:05+00:00

I have got few things to work e.g. Using – FB.login(function(response) { if (response.authResponse)

  • 0

I have got few things to work e.g. Using –

 FB.login(function(response) {
   if (response.authResponse) {
     console.log('Welcome!  Fetching your information.... ');
     FB.api('/me', function(response) {
       console.log('Good to see you, ' + response.name + '.');
     });
   } else {
     console.log('User cancelled login or did not fully authorize.');
   }
 });

I am able to get all the details of the user, name, User ID etc.

My Problem is how to take all this information to the server “safely”. I don’t want this information to be sniffed on its way to server. I use JAVA(Servet/JSP) language, PLEASE HELP ME ON THIS. I wish there was some way like registration plugin where Facebook sends all the information on a redirect_url link.

Regards,
Jagpreet Singh


EDIT: If anybody requires the Java Code –

    // it is important to enable url-safe mode for Base64 encoder
    Base64 base64 = new Base64(true);

    // split request into signature and data
    String[] signedRequest = request.getParameter("signed_request").split("\\.", 2);

    logger.info("Received signed_request = " + Arrays.toString(signedRequest));

    // parse signature
    String sig = new String(base64.decode(signedRequest[0].getBytes("UTF-8")));

    // parse data and convert to JSON object
    JSONObject data = (JSONObject) JSONSerializer.toJSON(new String(base64.decode(signedRequest[1].getBytes("UTF-8"))));

    logger.warn("JSON Value = " + data);

    // check signature algorithm
    if (!"HMAC-SHA256".equals(data.getString("algorithm"))) {
        // unknown algorithm is used
        logger.error("HMAC-SHA256 Algo? = false, returning ERROR");
        return ERROR;
    } else {
        logger.error("HMAC-SHA256 Algo? = true, Checking if data is signed correctly...");
    }

    // check if data is signed correctly
    if (!hmacSHA256(signedRequest[1], fbSecretKey).equals(sig)) {
        // signature is not correct, possibly the data was tampered with
        logger.warn("DATA signed correctly? = false, returning ERROR");
        return ERROR;
    } else {
        logger.warn("DATA signed correctly? = true, checking if user has authorized the APP...");
    }

    // check if user authorized the APP (FACEBOOK User)
    if (!data.has("user_id") || !data.has("oauth_token")) {
        // this is guest, create authorization url that will be passed
        // to javascript
        // note that redirect_uri (page the user will be forwarded to
        // after authorization) is set to fbCanvasUrl
        logger.warn("User has authorized the APP? = false, returning ERROR");
        return ERROR;
    } else {
        logger.warn("User has authorized the APP? = true, Performing User Registration...");

        // this is authorized user, get their info from Graph API using
        // received access token

        // String accessToken = data.getString("oauth_token");
        // FacebookClient facebookClient = new
        // DefaultFacebookClient(accessToken);
        // User user = facebookClient.fetchObject("me", User.class);
    }
  • 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-06-10T17:27:07+00:00Added an answer on June 10, 2026 at 5:27 pm

    Facebook sends a signed_request parameter when you authenticate with a client-side method. You can pass this to your server, authenticate it, and then unpack it to get at the information you need. It is encrypted with your app secret, so you can be sure that it is secure.

    See the signed_request documentation for more information.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have got a few tables which I am trying to join. I just
i have form in drupal which uploads images and has got few checkboxes in
So I have googled whole day, got few answers how to do this, and
I've got a few files that have been serialized by directly writing C++ struct
I have probem / strange question, i got algorithm with few for loops and
I have been working on this for few hours and got stuck, so how
I have looked at Spring MVC a few times briefly, and got the basic
I have got this code: function init(){ if (typeof window.jQuery !== 'function') { var
I've got a database that is mirrored using SQL 2008 Mirroring. I have a
I only got into PHP a few months ago and have been dabbing into

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.