From 66f7af90c334d8510b4f88295309c6c6e9c64a6a Mon Sep 17 00:00:00 2001 From: timination Date: Thu, 1 Oct 2020 17:45:01 +0100 Subject: [PATCH] Hotfix instagram api (#6922) * updated defaultURL to allow new insta API access * updated defaultURL to allow new insta API access * updates tests for new instagram API url Co-authored-by: Tim Talbot --- spec/AuthenticationAdapters.spec.js | 6 +++--- src/Adapters/Auth/instagram.js | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/AuthenticationAdapters.spec.js b/spec/AuthenticationAdapters.spec.js index 9b172cdf..a6b31086 100644 --- a/spec/AuthenticationAdapters.spec.js +++ b/spec/AuthenticationAdapters.spec.js @@ -66,7 +66,7 @@ describe('AuthenticationProviders', function () { }); it(`should provide the right responses for adapter ${providerName}`, async () => { - const noResponse = ['twitter', 'apple', 'gcenter', "google", 'keycloak']; + const noResponse = ['twitter', 'apple', 'gcenter', 'google', 'keycloak']; if (noResponse.includes(providerName)) { return; } @@ -527,7 +527,7 @@ describe('instagram auth adapter', () => { {} ); expect(httpsRequest.get).toHaveBeenCalledWith( - 'https://api.instagram.com/v1/users/self/?access_token=the_token' + 'https://graph.instagram.com/me?fields=id&access_token=the_token' ); }); @@ -544,7 +544,7 @@ describe('instagram auth adapter', () => { {} ); expect(httpsRequest.get).toHaveBeenCalledWith( - 'https://new-api.instagram.com/v1/users/self/?access_token=the_token' + 'https://new-api.instagram.com/v1/me?fields=id&access_token=the_token' ); }); }); diff --git a/src/Adapters/Auth/instagram.js b/src/Adapters/Auth/instagram.js index 4cbeba64..0c1379d4 100644 --- a/src/Adapters/Auth/instagram.js +++ b/src/Adapters/Auth/instagram.js @@ -1,12 +1,12 @@ // Helper functions for accessing the instagram API. var Parse = require('parse/node').Parse; const httpsRequest = require('./httpsRequest'); -const defaultURL = 'https://api.instagram.com/v1/'; +const defaultURL = 'https://graph.instagram.com/'; -// Returns a promise that fulfills iff this user id is valid. +// Returns a promise that fulfills if this user id is valid. function validateAuthData(authData) { const apiURL = authData.apiURL || defaultURL; - const path = `${apiURL}users/self/?access_token=${authData.access_token}`; + const path = `${apiURL}me?fields=id&access_token=${authData.access_token}`; return httpsRequest.get(path).then(response => { if (response && response.data && response.data.id == authData.id) { return;