Posted by Igor Benic

Web Developer who mainly uses WordPress for projects. Working on various project through Codeable & Toptal. Author of several ebooks at https://leanpub.com/u/igorbenic.

11 Comments

  1. This has been extremely helpful in getting my headless WP backend up and running using the facebook login SDK!! Its very rare to find help on headless wp builds/setups & process, site bookmarked! Great job of explaining and code sharing. Thank you so much for all the help!

    Reply

    1. Hey Igor and Spencer,

      I was looking also for Facebook login implementation.

      Would you like to share yours?

      Reply

  2. How can I setup autoload help me please

    Reply

    1. Once you install the packages using composer, the autoload.php provided by composer will be enough to autoload classes.

      If you have not yet been introduced to composer, you can check their site: https://getcomposer.org/

      If you would like create your own custom autoloaders, you can then here is an article from Tom McFarlin about creating autoloaders for WordPress projects: https://tommcfarlin.com/simple-autoloader-for-wordpress/

      Reply

  3. protected $googleClient = ‘YOUR_GOOGLE_CLIENT_ID’;

    should i replace ‘YOUR_GOOGLE_CLIENT_ID’ with id i get from google console ?

    Reply

    1. Yes, that’s the long google client id. You can see for example in their own code example: https://developers.google.com/identity/sign-in/web/build-button#building_a_button_with_a_custom_graphic how they use the client ID.

      But in this code you use the whole part (.apps.googleusercontent.com included).

      Reply

      1. thank you very much , implemented with React-native / wp backend
        and it work like a charm

        Reply

  4. Wisnu Eka Saputra February 5, 2020 at 7:56 am

    Hey. Thanks for your tutorial dude. It works on localhost but when on live site it returns 404 route not found. Can you help me?

    Reply

    1. Hi Wisnu, if I understood correctly, the route is 404? Not page 404?

      In case the route is 404 (not found) it might be that the URL to the route is incorrect or some other plugin is maybe blocking that?

      Or try updating permalinks (Settings > Permalinks > Save Changes). It should not be related to permalinks but you never know 🙂

      Reply

      1. Wisnu Eka Saputra February 11, 2020 at 8:18 am

        Nice man, thanks. but i get invalid-token code when i try to post on post man. i get the id_token from developers.google.com/oauthplayground. i check on jwt.io it contain the userdata from google. but still return invalid-token. how can i resolve that? thanks

        Reply

  5. In the class-login-2.php file, I do not see the Client.php in the mentioned path ‘/vendor/google/apiclient/src/Google/Client.php’.
    Also this path ‘\Firebase\JWT\JWT;’

    I have downloaded the google client api from the below links, I checked in both of the zip files.
    https://github.com/googleapis/google-api-php-client/releases
    google-api-php-client-2.5.0.zip
    google-api-php-client-2.5.0_PHP54.zip

    can anyone tell how I have to setup Google Client API without composer.

    Reply

Leave a reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.