Skip to main content

Facebook Login Helpful links













How to implement Facebook native login with Meteor?


Aman Gupta

Aman Gupta


Co-Founded YourMarch · Entrepreneur · Designer · Engineer · Coder

About Meteor & Facebook Login

Meteor is a full-stack JavaScript platform for developing modern web and mobile applications. Meteor provides in build methods for logging in to various services like Facebook, Google, GitHub, etc. However, these methods are not configured to login with these services natively i.e. using credentials from the Facebook app installed on your device. In this article, I am going to explain how you can implement native Facebook login for your Meteor App.

Prerequisites

  1. Prerequisites for android development in meteor.
  2. Facebook App in Facebook Developer Console.
  3. Meteor app with default Facebook login i.e. Meteor.loginWithFacebook() along with ServiceConfiguration.configurations, more details about the same over here.

Procedure

Configure Facebook App

  • Provide Google Play Package Name as com.example.app, replace it with your app name.
  • Provide Class Name as com.facebook.LoginActivity.
  • Generate Key Hashes using
keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64
  • Click Save Changes.

Configure Android Platform

  • Run meteor add android-platform in your Meteor project.
  • Add mobile-config.js at the root of your Meteor project.
App.info({
    id: 'com.example.app',
    version: '0.0.1',
    name: 'NativeFacebook',
    author: 'Aman Gupta',
    description: 'How to implement Facebook Native Login with Meteor?',
    email: 'aman.gupta@outlook.in',
    website: 'http://startupaman.com'
});

App.accessRule("*");

Configure Cordova Plugin

  • Run meteor add cordova:cordova-plugin-facebook4@1.9.1 in your Meteor project.
  • Add following configuration in your mobile-config.js
App.configurePlugin('cordova-plugin-facebook4', {
    APP_ID: '[app_id]',
    APP_NAME: 'NativeFacebook'
});

Override Meteor Login Methods

  • Run meteor remove accounts-facebook in your Meteor project.
  • Run meteor add btafel:accounts-facebook-cordova in your Meteor project.
  • Add settings.json to your Meteor project.
{
  "facebook": {
    "appId": "[app_id]",
    "secret": "[app_secret]"
  },
  "public": {
    "facebook": {
      "permissions": [
        "basic_info", 
        "user_interests", 
        "user_activities", 
        "read_friendlists"
      ]   
      "profileFields": [
        "name",
        "gender",
        "location"
      ]   
    }
  }
}

Run Meteor Project

  • Since Meteor’s OAuth2 login doesn’t work with mobile apps in local development mode. This limitation is because you need a public Internet address to register as an authorized redirect URL with the login provider. As a workaround, you can deploy your app and modify your app’s configuration to test OAuth login on a mobile app when developing locally.
  • Run meteor run android-device --mobile-server http://deployed-server-url.com --settings settings.json --verbose to run your Meteor project.
You can follow these steps to integrate Facebook native login to your Meteor Android App. Also, you can generalize certain steps and extend it to iOS also. I hope you will find this procedure helpful.

If you liked this article, be sure to recommend it and help spread good ideas as far and wide as possible just like the broadness of Technology. Please also leave your responses below :-)
Aman Gupta is Co-founder & CEO of YourMarch. He is working with his team on this disruptive platform to bring governance and technology on the same plate. He is very passionate about the way technology can be used to disrupt old models of democracy where the contribution of citizens was limited.
In his free time, you can find him playing games, lots of games :-). You can follow him on TwitterFacebook or connect with him on LinkedIn.
This article originally appeared in his Personal Blog “Startup Aman!”.


Comments

Popular posts from this blog

curl http://localhost:8042/studies/333b2c11-52e9feea-5516186e-ecd61f37-69da2603  curl http://localhost:8042/patients/dc65762c-f476e8b9-898834f4-2f8a5014-2599bc94 bird@bird-Lenovo-ideapad-310-15IKB:/media/bird/2AE477A5E4777245/Meteor/OrthancMirror/build$ curl http://localhost:8042/patients [    "333b2c11-52e9feea-5516186e-ecd61f37-69da2603",    "da39a3ee-5e6b4b0d-3255bfef-95601890-afd80709" ] bird@bird-Lenovo-ideapad-310-15IKB:/media/bird/2AE477A5E4777245/Meteor/OrthancMirror/build$ curl http://localhost:8042/studies [    "9b5629ef-c28c48db-b3593009-35fda9cb-7a0bb799",    "abae0b24-5a718d9e-1b560140-2cda3ae0-30b846cb" ] bird@bird-Lenovo-ideapad-310-15IKB:/media/bird/2AE477A5E4777245/Meteor/OrthancMirror/build$  curl http://localhost:8042/series [    "993a521c-1b11574c-92e1c71d-a048784c-36866be0",    "5f19601c-3e5fa872-e566e9f2-36aa3b31-dc719c3e" ] bird@bird-Lenovo-ideapad-310-15IKB:/med...

Android Commands

meteor run android-device --mobile-server="https://sitename.com" metero build (BUIld Path/home/bird/Downloads/Meteor/bit/uploads ) --server="https://sitename.com"

Using LetsEncrypt to install free SSL on AWS server ec2 machine( Meteor version 1.6)

Installation of meteor project on AWS could be a real headache if you are not familiar with AWS environment. But with the help of various blogs on Medium, you can Do the installation and your project would be live. But there is one more thing that usually causes severe pain for Developers. that is the installation of SSL certificate. Most of the content on the web is almost 2-3 years old. So many things got changed since then. so we felt an utter need for a blog that could guide us through this process. let's start. 1. Login with SSH command on your Ubuntu machine. 2. Go to your project directory by typing cd /var/www/html/ 3. go inside your project and then in app-deploy folder. Now run mup stop command to stop the current instance that is running on the server. Now go out with cd .. command to HTML folder( cd /var/www/html/ ). 4. Now install LetsEncrypt on your virtual machine. type this command git clone https://github.com/letsencrypt/letse...