Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit 48ba3cf

Browse files
Merge pull request #338 from abhayastudios/master
Return Facebook access token to login result for use with FB SDK
2 parents 0b6e9aa + 5687714 commit 48ba3cf

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

docs/AUTHENTICATION.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,18 @@ Then add the following lines to your code and check for setup instructions for y
256256

257257
For a complete list of the available scope permissions, visit Facebook's documentation: https://developers.facebook.com/docs/facebook-login/permissions.
258258

259+
#### Post-login Graph API querying
260+
Upon successful authentication, Facebook creates an access token that can be obtained from the login method's result object. This access token can then be used for querying the Facebook Graph API, by feeding it to either Facebook's Javascript SDK or their iOS/Android native SDKs:
261+
262+
```js
263+
"providers": [
264+
{
265+
"id": "facebook.com",
266+
"token": "<FB token>"
267+
}
268+
]
269+
```
270+
259271
#### iOS
260272
1. If you didn't choose this feature during installation you can open the `Podfile` in the plugin's `platforms/ios` folder and uncomment the Facebook line.
261273
2. Add a bit of config to `app\App_Resources\iOS\Info.plist` as instructed in Step 4 [here](https://developers.facebook.com/docs/ios/getting-started).

firebase.android.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -777,9 +777,8 @@ function toLoginResult(user) {
777777
var providerData = user.getProviderData();
778778
for (var i = 0; i < providerData.size(); i++) {
779779
var pid = providerData.get(i).getProviderId();
780-
providers.push({
781-
id: pid
782-
});
780+
if (pid==='facebook.com') { providers.push({ id: pid, token: firebase._facebookAccessToken }); }
781+
else { providers.push({ id: pid }); }
783782
}
784783

785784
return {

firebase.ios.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -856,9 +856,8 @@ function toLoginResult(user) {
856856
for (i = 0, l = user.providerData.count; i < l; i++) {
857857
var firUserInfo = user.providerData.objectAtIndex(i);
858858
var pid = firUserInfo.valueForKey("providerID");
859-
providers.push({
860-
id: pid
861-
});
859+
if (pid==='facebook.com') { providers.push({ id: pid, token: FBSDKAccessToken.currentAccessToken().tokenString }); }
860+
else { providers.push({ id: pid }); }
862861
}
863862

864863
return {

0 commit comments

Comments
 (0)