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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:43:14+00:00 2026-06-18T05:43:14+00:00

I am developing an Phonegap based application, that uses Facebook OAuth for SSO login.

  • 0

I am developing an Phonegap based application, that uses Facebook OAuth for SSO login. How to validate the FB.login javascript response on server side? After successful redirection from Facebook mobile back to my app I get the userId and accessToken. It is enough to check the accesToken to gain access for the User on the server?

https://graph.facebook.com/me?fields=id&access_token=...

My Problem is JS & PHP mix on mobile and web:
The user uses FB.login on mobile (Javascript) and returns sucessfully (client), because the user has already connected via web. Now I can check the FB id in my database to load the user credentials via AJAX request. How to make the AJAX request secure. The prototype will login everyone that passes a valid FB, which exits in my DB too. So the system is open to get a session without revalidating on FB (server). My Idea was to check if the accessToken is valid, but not sure if this is enough… I think is is not… maybe check IP too?

  • 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-18T05:43:15+00:00Added an answer on June 18, 2026 at 5:43 am

    Using the SignedRequest instead of accessToken seams to be the correct choice for my needs, e.g. PHP solution, using app secret.

    private function check_signed_request($signed_request) {
    
        $secret = Semods_Utils::getSetting('socialdna.facebook_secret','');
        list($encoded_sig, $payload) = explode('.', $signed_request, 2);
    
        // decode the data
        $sig = $this->base64_url_decode($encoded_sig);
        $data = json_decode($this->base64_url_decode($payload), true);
    
        if (strtoupper($data['algorithm']) !== 'HMAC-SHA256') {
            throw new Exception('Unknown algorithm. Expected HMAC-SHA256');
        }
    
        // Adding the verification of the signed_request below
        $expected_sig = hash_hmac('sha256', $payload, $secret, $raw = true);
        if ($sig !== $expected_sig) {
            throw new Exception('Bad Signed JSON signature!');            
        }
    
        return true;
    }
    
    private function base64_url_decode($input) {
        return base64_decode(strtr($input, '-_', '+/'));
    }
    

    see: https://developers.facebook.com/docs/howtos/login/signed-request/

    PROBLEM
    I did not receive the signed_request, these are undefined:

    response.authResponse.signed_request
    response.authResponse.signedRequest
    

    and the this one contains only “…”

    response.authResponse.sig
    

    Anyone an idea?

    EDIT
    Ok .sig seam to be provided only by my plugin, hard coded: so the fix should bein there https://github.com/davejohnson/phonegap-plugin-facebook-connect

    But reported:
    https://github.com/davejohnson/phonegap-plugin-facebook-connect/issues/245

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

Sidebar

Related Questions

I'm developing a phonegap based application, and I also need to call javascript from
I have a PhoneGap application I am developing for iPad that uses video extensively,
I'm developing a web application that uses PhoneGap:Build for a mobile version and want
I am developing a BlackBerry Phonegap application. Therefore, I am using JavaScript. From a
I developing android application in phonegap I want to call javascript form my main
I am developing a phonegap application that sends the current GPS location to a
I am developing blackberry application using PhoneGap. When in LogIn page if invalid credentials
I am developing a phonegap application on Android which uses ajax requests to the
I'm developing an iOS phonegap application which receives messages from a node.js/socket.io server. Everything
What is the performance trade off of using PhoneGap for developing an application that

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.