Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for authenticating with instagram #7173

Merged
merged 3 commits into from
Feb 19, 2021

Conversation

OverDriveGain
Copy link
Contributor

New Pull Request Checklist

Issue Description

Instagram authentication is not working, it always returns 'Instagram auth is invalid for this user.'

The response of function httpsRequest.get(path) does not include the data object.

The user id is directly presented in the response

Approach

Remove the 'data' part from 'response.data'

TODOs before merging

  • Add test cases
  • Add entry to changelog
  • Add changes to documentation (guides, repository pages, in-code descriptions)
  • Add security check
  • Add new Parse Error codes to Parse JS SDK
  • ...

Copy link
Member

@dplewis dplewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like the proper fix after looking at the API

https://developers.facebook.com/docs/instagram-basic-display-api/reference/user

@@ -8,7 +8,7 @@ function validateAuthData(authData) {
const apiURL = authData.apiURL || defaultURL;
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) {
if (response && response.id == authData.id) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CI build is failing. Can you update the tests to match your change?

Copy link
Member

@dplewis dplewis Feb 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you using any API urls or just the default graph.instagram.com? You could easily support both response and response.data.

const user = response.data ? response.data : response;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use defaultURL.

OK I will apply support for both response, and response.data

I will try to figure out how to update the tests. In the meantime I would appreciate it if you can refer me to some instructions on how to update the test.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can checkout the Contributing Guide

You can see that tests are failing in the CI.

The tests you are looking for should be here

Copy link
Contributor Author

@OverDriveGain OverDriveGain Feb 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks very much!

I will update the test. But you mentioned earlier that I can support response and response.data. Are you sure it would be a good practice?. In the test you send it can only cover one of the cases

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just copy the existing test and create a new test one. I think its best practice as I don't want a breaking change with older urls.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late response, but I really spent many hours trying to find the older urls where the response includes data child object, but I didn't find any. Are you sure this was working at one point? Anyway I pushed new changes, for covering also older urls

@codecov
Copy link

codecov bot commented Feb 12, 2021

Codecov Report

Merging #7173 (1b8cf03) into master (7f47b04) will decrease coverage by 0.00%.
The diff coverage is 93.88%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #7173      +/-   ##
==========================================
- Coverage   94.00%   94.00%   -0.01%     
==========================================
  Files         172      172              
  Lines       12835    12868      +33     
==========================================
+ Hits        12066    12097      +31     
- Misses        769      771       +2     
Impacted Files Coverage Δ
src/cloud-code/Parse.Cloud.js 98.73% <ø> (ø)
src/Adapters/Storage/Mongo/MongoStorageAdapter.js 92.92% <57.14%> (-0.60%) ⬇️
src/triggers.js 94.87% <94.44%> (+0.27%) ⬆️
src/LiveQuery/ParseLiveQueryServer.js 95.33% <94.93%> (+0.40%) ⬆️
src/batch.js 91.37% <95.65%> (-0.93%) ⬇️
src/ParseServerRESTController.js 97.01% <96.00%> (-1.35%) ⬇️
src/Adapters/Auth/instagram.js 91.66% <100.00%> (-8.34%) ⬇️
src/Controllers/LiveQueryController.js 96.42% <100.00%> (-0.13%) ⬇️
src/Controllers/UserController.js 97.63% <100.00%> (ø)
src/RestQuery.js 95.53% <100.00%> (+<0.01%) ⬆️
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7f47b04...35fe088. Read the comment docs.

Copy link
Member

@dplewis dplewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you contributing!

@dplewis dplewis merged commit a1cd631 into parse-community:master Feb 19, 2021
dplewis pushed a commit that referenced this pull request Feb 21, 2021
* Fix for authenticating with instagram

* Change tests for instagram authentication

* Instagram authentication for the case when data child object is presented in the response
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 5.0.0-beta.1

@parseplatformorg parseplatformorg added the state:released-beta Released as beta version label Nov 1, 2021
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 5.0.0

@parseplatformorg parseplatformorg added the state:released Released as stable version label Mar 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state:released Released as stable version state:released-beta Released as beta version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants