Skip to content
This repository was archived by the owner on Dec 7, 2021. It is now read-only.

Commit 6051b68

Browse files
authored
Merge pull request #68 from adamjmcgrath/facebook-fix
Facebook fix
2 parents b887f44 + 3bb8417 commit 6051b68

File tree

3 files changed

+2
-38
lines changed

3 files changed

+2
-38
lines changed

lib/fixtures/facebook.js

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,6 @@ const DANCE_CALLBACK = `fb0123456789://authorize#
1010
expires_in=12345
1111
`.replace(/\s+/g, '');
1212

13-
const VERIFY_URL = `https://graph.facebook.com/debug_token?
14-
input_token=ACCESSTOKEN123&
15-
access_token=ACCESSTOKEN123
16-
`.replace(/\s+/g, '');
17-
18-
const VERIFY_RESPONSE = {
19-
data: {
20-
app_id: 'APPID123',
21-
application: 'Test App',
22-
expires_at: 123456789,
23-
is_valid: true,
24-
scopes: [
25-
'email',
26-
'public_profile',
27-
],
28-
user_id: 'USER123',
29-
},
30-
};
31-
3213
const USER_INFO_URL = `https://graph.facebook.com/v2.8/me?
3314
fields=id,name,first_name,last_name,verified,email,location,link&
3415
access_token=ACCESSTOKEN123
@@ -43,6 +24,5 @@ const USER_INFO_RESPONSE = {
4324
export const DANCE = [AUTH_URL, DANCE_CALLBACK];
4425

4526
export const REQUESTS = [
46-
[VERIFY_URL, {}, VERIFY_RESPONSE, 'verify token'],
4727
[USER_INFO_URL, {}, USER_INFO_RESPONSE, 'get user info'],
4828
];

lib/providers/facebook.js

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
import {
22
__,
33
curry,
4-
equals,
5-
identity,
6-
ifElse,
74
invoker,
85
lensProp,
9-
merge,
106
partial,
11-
pathSatisfies,
127
pipeP,
138
replace,
149
set,
@@ -20,27 +15,16 @@ import { fromQueryString } from '../utils/uri';
2015

2116
const SCOPE = 'email public_profile';
2217
const AUTH = 'https://www.facebook.com/dialog/oauth';
23-
const DEBUG_TOKEN = 'https://graph.facebook.com/debug_token';
2418
const ME = 'https://graph.facebook.com/v2.8/me?fields=' +
2519
'id,name,first_name,last_name,verified,email,location,link';
2620

27-
const checkAppId = curry((appId, obj) => ifElse(
28-
pathSatisfies(equals(appId), ['data', 'app_id']),
29-
identity,
30-
() => { throw new Error('AppIds don\'t match.'); },
31-
)(obj));
32-
3321
export const authorize = ({ dance, request }, { appId, callback }) => pipeP(
3422
dance,
3523
replace('#', '?'),
3624
fromQueryString,
37-
merge({ appId }),
3825
)(authorizationUrl(AUTH, appId, callback, SCOPE));
3926

40-
export const identify = curry((request, { appId, ...credentials }) => pipeP(
41-
partial(request, [`${DEBUG_TOKEN}?input_token=${credentials.access_token}&access_token=${credentials.access_token}`, {}]), // eslint-disable-line max-len
42-
invoker(0, 'json'),
43-
checkAppId(appId),
27+
export const identify = curry((request, credentials) => pipeP(
4428
partial(request, [`${ME}&access_token=${credentials.access_token}`, {}]),
4529
invoker(0, 'json'),
4630
set(lensProp('user'), __, {}),

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-simple-auth",
3-
"version": "2.0.0",
3+
"version": "2.0.1",
44
"description": "Native social authentication for React Native",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)