Skip to content

Commit

Permalink
Updates Facebook API to v2.9 (hapijs#311)
Browse files Browse the repository at this point in the history
* [Update] Updates facebook API to v2.7

* [Fix] Fixes reference to old facebook API version.

* [Update] Updates facebook API mocks to v2.7

Updates facebook API mocks to v2.7

* [Update] Updates facebook oAuth tests.

Update facebook oAuth tests.

* Updates facebook API to v2.8. Will need further testing.

* Updates to facebook v2.9 API.

* Updates missing API calls for oAuth.
  • Loading branch information
kamronbatman authored and ldesplat committed May 9, 2017
1 parent 48eefb0 commit 3f64290
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions lib/providers/facebook.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ exports = module.exports = function (options) {
return {
protocol: 'oauth2',
useParamsAuth: true,
auth: 'https://www.facebook.com/v2.3/dialog/oauth',
token: 'https://graph.facebook.com/v2.3/oauth/access_token',
auth: 'https://www.facebook.com/v2.9/dialog/oauth',
token: 'https://graph.facebook.com/v2.9/oauth/access_token',
scope: ['email'],
scopeSeparator: ',',
profile: function (credentials, params, get, callback) {
Expand All @@ -21,7 +21,7 @@ exports = module.exports = function (options) {
fields: 'id,name,email,first_name,last_name,middle_name,gender,link,locale,timezone,updated_time,verified'
};

get('https://graph.facebook.com/v2.3/me', query, (profile) => {
get('https://graph.facebook.com/v2.9/me', query, (profile) => {

credentials.profile = {
id: profile.id,
Expand Down
14 changes: 7 additions & 7 deletions test/oauth.js
Original file line number Diff line number Diff line change
Expand Up @@ -1983,7 +1983,7 @@ describe('Bell', () => {
const custom = Bell.providers.facebook();
Hoek.merge(custom, provider);

Mock.override('https://graph.facebook.com/v2.3/me', null);
Mock.override('https://graph.facebook.com/v2.9/me', null);

server.auth.strategy('custom', 'bell', {
password: 'cookie_encryption_password_secure',
Expand Down Expand Up @@ -2037,7 +2037,7 @@ describe('Bell', () => {
const custom = Bell.providers.facebook();
Hoek.merge(custom, provider);

Mock.override('https://graph.facebook.com/v2.3/me', Boom.badRequest());
Mock.override('https://graph.facebook.com/v2.9/me', Boom.badRequest());

server.auth.strategy('custom', 'bell', {
password: 'cookie_encryption_password_secure',
Expand Down Expand Up @@ -2091,7 +2091,7 @@ describe('Bell', () => {
const custom = Bell.providers.facebook();
Hoek.merge(custom, provider);

Mock.override('https://graph.facebook.com/v2.3/me', '{c');
Mock.override('https://graph.facebook.com/v2.9/me', '{c');

server.auth.strategy('custom', 'bell', {
password: 'cookie_encryption_password_secure',
Expand Down Expand Up @@ -2341,10 +2341,10 @@ describe('Bell', () => {
const custom = Bell.providers.facebook();
Hoek.merge(custom, provider);

Mock.override('https://graph.facebook.com/v2.3/me', (uri) => {
Mock.override('https://graph.facebook.com/v2.9/me', (uri) => {

Mock.clear();
expect(uri).to.equal('https://graph.facebook.com/v2.3/me?appsecret_proof=d32b1d35fd115c4a496e06fd8df67eed8057688b17140a2cef365cb235817102&fields=id%2Cemail%2Cpicture%2Cname%2Cfirst_name%2Cmiddle_name%2Clast_name%2Clink%2Clocale%2Ctimezone%2Cupdated_time%2Cverified%2Cgender');
expect(uri).to.equal('https://graph.facebook.com/v2.9/me?appsecret_proof=d32b1d35fd115c4a496e06fd8df67eed8057688b17140a2cef365cb235817102&fields=id%2Cemail%2Cpicture%2Cname%2Cfirst_name%2Cmiddle_name%2Clast_name%2Clink%2Clocale%2Ctimezone%2Cupdated_time%2Cverified%2Cgender');
mock.stop(done);
});

Expand Down Expand Up @@ -2398,10 +2398,10 @@ describe('Bell', () => {
const custom = Bell.providers.facebook();
Hoek.merge(custom, provider);

Mock.override('https://graph.facebook.com/v2.3/me', (uri) => {
Mock.override('https://graph.facebook.com/v2.9/me', (uri) => {

Mock.clear();
expect(uri).to.equal('https://graph.facebook.com/v2.3/me?appsecret_proof=d32b1d35fd115c4a496e06fd8df67eed8057688b17140a2cef365cb235817102&fields=id%2Cemail%2Cpicture%2Cname%2Cfirst_name%2Cmiddle_name%2Clast_name%2Clink%2Clocale%2Ctimezone%2Cupdated_time%2Cverified%2Cgender');
expect(uri).to.equal('https://graph.facebook.com/v2.9/me?appsecret_proof=d32b1d35fd115c4a496e06fd8df67eed8057688b17140a2cef365cb235817102&fields=id%2Cemail%2Cpicture%2Cname%2Cfirst_name%2Cmiddle_name%2Clast_name%2Clink%2Clocale%2Ctimezone%2Cupdated_time%2Cverified%2Cgender');
mock.stop(done);
});

Expand Down
2 changes: 1 addition & 1 deletion test/providers/facebook.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe('facebook', () => {
email: 'steve@example.com'
};

Mock.override('https://graph.facebook.com/v2.3/me', profile);
Mock.override('https://graph.facebook.com/v2.9/me', profile);

server.auth.strategy('custom', 'bell', {
password: 'cookie_encryption_password_secure',
Expand Down

0 comments on commit 3f64290

Please sign in to comment.