Facebook OAuth Proxy

If you're already authenticating your users with Facebook OAuth, you can use Dailycred as a proxy to use our dashboard. Migration is dead simple.

The two methods for authenticating with Facebook are through their OAuth flow and their javascript SDK. We have a tailored migration solution for both options.

OAuth Flow

If you're following Facebook's server side flow, using Dailycred as a proxy requires very few changes.

First, change the URL that you initially send your user to from Facebook to Dailycred.

From:

  https://www.facebook.com/dialog/oauth?
    client_id={facebook-app-id}
    &redirect_uri={redirect-uri}

To:

  https://www.dailycred.com/connect?identity_provider=facebook&
    client_id={dailycred-app-id}
    &redirect_uri={redirect-uri}

You can find your App ID in your settings. You can pass any state, response_type, and scope parameters just as you used to.

Canceled Login

If your user cancels during the login flow, they will be redirected to your redirect URL just as before.

  YOUR_REDIRECT_URI?
    error_reason=user_denied
    &error=access_denied
    &error_description=The+user+denied+your+request.

Successful Login

Your user will be redirected back to your redirect URL with the exact same parameters that Facebook returns. If you specified response_type=token in your request (also called the client-side flow), an access_token will be in the hash fragment of the response, just as before. Otherwise, you will have to change the URL you use to exchange a code for an access_token.

From:

  https://graph.facebook.com/oauth/access_token?
    client_id={facebook-app-id}
    &redirect_uri={redirect-uri}
    &client_secret={facebook-app-secret}
    &code={code-parameter}

To:

  https://www.dailycred.com/oauth/access_token
    client_id={dailycred-app-id}
    &redirect_uri={redirect-uri}
    &client_secret={dailycred-app-secret}
    &code={code-parameter}

We will return JSON similar to Facebook's response that looks like the following:

  {
    access_token: '[YOUR_TOKEN]',
    worked : true
  }

Then change the URL you use to fetch the user's information using the access token you received from Dailycred:

From:

  https://graph.facebook.com/me?
    access_token={facebook-access-token}

To:

  https://www.dailycred.com/graph/me?
    access_token={dailycred-access-token}

Example Dailycred Response

  {
  "is_email_verified": true,
  "access_tokens": {
    "dailycred": "c3681ad2-250a-4985-ae8a-fdad48123235",
    "google": "ya31.AHES6ZTp2HijFmiz3EthqpOB5e6EqEje5_0eI25UB9Jn_MP0ERlGAg",
    "facebook": "AAADuiLHgPRcBEAplxD9I22dWzx9nW18KdvpDUdBRy8UqrdykTSJui8YPJMSF8rR2OKTzjod8kZBOXy939eTCOUOp26ONOrehFKPTYCQZDZD",
    "twitter": "44431966-TgD3VOLgxDv91bsHDDLtuEaupBVueaI512yLYLhjY"
  },
  "updated_at": 1348881437129,
  "id": "a4babca4-1157-4314-b793-024b62093998",
  "display": "joesmith@dailycred.com",
  "guest": false,
  "username": "jsmitty",
  "identities": {
    "google": {
      "name": "Joe Smith",
      "id": "112885788772526071521",
      "family_name": "Stoever",
      "verified_email": true,
      "given_name": "Joseph",
      "email": "joesmith@dailycred.com"
    },
    "facebook": {
      "video_upload_limits": {
        "size": 1073741824,
        "length": 1200
      },
      "name": "Joe Smith",
      "username": "jsmitty",
      "third_party_id": "dGHzTuS8IjX9acsnQIeJDE6kKgM",
      "gender": "male",
      "id": "1092690821",
      "last_name": "Smith",
      "currency": {
        "currency_exchange_inverse": 0.1,
        "currency_offset": 100,
        "currency_exchange": 10,
        "user_currency": "USD"
      },
      "bio": "I love dailycred!",
      "verified": true,
      "updated_time": "2012-09-27T19:04:38+0000",
      "link": "http://www.facebook.com/jsmitty",
      "locale": "en_US",
      "picture": {
        "data": {
          "is_silhouette": false,
          "url": "http://profile.ak.fbcdn.net/hprofile-ak-ash4/370570_1092690812_2022945351_q.jpg"
        }
      },
      "email": "jsmitty@gmail.com",
      "first_name": "Joe"
    }
  },
  "created": 1348873419043,
  "email": "joesmith@dailycred.com"
}