Skip to content

Instantly share code, notes, and snippets.

@evangow
evangow / authenticateChromeExtensionWithFacebook.md
Last active October 21, 2020 19:54
authenticate a Chrome Extension with Facebook
// To download the Facebook SDK and access the Graph API, you should
// update the content security policy in your manifest.json with the below
"content_security_policy": "script-src 'self' https://connect.facebook.net https://graph.facebook.com; object-src 'self'"

// The rest of the code below can be added to the javascript file of
// one of your UI pages

// Download Facebook's Javascript SDK as shown in Facebook's docs.
// Note, you must call "https://connect.facebook.net/en_US/sdk.js"
@evangow
evangow / content_security_policy.md
Last active September 29, 2017 13:45
content security policy for download Facebook SDK in a Chrome Extension
"content_security_policy": "script-src 'self' https://connect.facebook.net https://graph.facebook.com; object-src 'self'"
@evangow
evangow / download_fb_sdk.md
Last active September 29, 2017 13:53
How to download the Facebook SDK inside a chrome extension
window.fbAsyncInit = function() {
      FB.init({
        appId            : '<your-app-id>',
        autoLogAppEvents : true,
        xfbml            : true,
        version          : 'v2.10'
      });

 FB.AppEvents.logPageView();
@evangow
evangow / authenticateWithFacebook.md
Last active September 29, 2017 16:20
How to make an authentication request with Facebook inside a chrome extension
authenticateWithFacebook = () => {
  return new Promise((resolve, reject) => {
    const TYPE = 'token';
    const RANDOM_STRING = uuid.v4();
    const URI = chrome.identity.getRedirectURL();
    const AUTH_URL = `https://www.facebook.com/v2.10/dialog/oauth?
          client_id=${CLIENT_ID}
          &redirect_uri=${URI}
          &state=${RANDOM_STRING}
@evangow
evangow / loadGroupFeed.md
Created September 29, 2017 17:12
How to call the Facebook API with your access token
loadGroupFeed = (accessToken) => {
  return new Promise((resolve, reject) => {
    FB.api(
      "/<Group-ID-here>/feed",
      { access_token: accessToken },
      function (response) {
        if (!response || response.error) {
          reject(response.error)
 } else {
//npm modules
const express = require('express');

// create the server
const app = express();

// tell the server what port to listen on
app.listen(3000, () => {
 console.log('Listening on localhost:3000')
//npm modules
const express = require('express');

// create the server
const app = express();

// create the homepage route at '/'
app.get('/', (req, res) => {
 res.send('you just hit the home page\n')
//npm modules
const express = require('express');

// create the server
const app = express();

// create the homepage route at '/'
app.get('/', (req, res) => {
 console.log(req)
//npm modules
const express = require('express');
const uuid = require('uuid').v4

// create the server
const app = express();

// create the homepage route at '/'
app.get('/', (req, res) =&gt; {
//npm modules
const express = require('express');
const uuid = require('uuid/v4')
const session = require('express-session')

// create the server
const app = express();

// add &amp; configure middleware