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 Twitter API Oauth Error #7370

Merged
merged 5 commits into from
Apr 25, 2021

Conversation

dblythy
Copy link
Member

@dblythy dblythy commented Apr 24, 2021

New Pull Request Checklist

Issue Description

Fixes the failing test explained in #7369.

Approach

Changes the endpoint that the GET request makes from https://api.twitter.com/1.1/help/configuration.json to https://api.twitter.com/1.1/oauth/request_token.

@codecov
Copy link

codecov bot commented Apr 24, 2021

Codecov Report

Merging #7370 (8ac31c4) into master (181fbf9) will decrease coverage by 0.00%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #7370      +/-   ##
==========================================
- Coverage   93.92%   93.92%   -0.01%     
==========================================
  Files         181      181              
  Lines       13195    13195              
==========================================
- Hits        12394    12393       -1     
- Misses        801      802       +1     
Impacted Files Coverage Δ
src/batch.js 91.37% <0.00%> (-1.73%) ⬇️

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 181fbf9...8ac31c4. Read the comment docs.

@mtrezza
Copy link
Member

mtrezza commented Apr 24, 2021

Thanks for opening this PR.

I think this PR is incorrect. I don't understand why you suggest to change the endpoint, unless the test used an incorrect endpoint to begin with.

The two endpoints seem to be for completely different purposes and the test in this PR may only pass because endpoint (b) returns a JSON (albeit with different content) which makes auth fail as the test expects.

My guess is that endpoint (a) is just temporarily down or has been throttled for us because:

It is recommended applications request this endpoint when they are loaded, but no more than once a day.

Conclusion:

  • Investigate which endpoint the test requires
  • If the test requires endpoint (a), investigate why the endpoint doesn't work instead of replacing it
  • Make test more robust, because it seems to fail for whatever reason, as long as the API responds with a JSON

@dblythy
Copy link
Member Author

dblythy commented Apr 24, 2021

Hey @mtrezza, thanks for your comments. You’re correct, as the current endpoint has worked for so long, perhaps it’s a Twitter issue. The change in this PR simply changes the endpoint without attempting to understand why the existing endpoint no longer works (I’m assuming it is depreciated). Perhaps the best approach is wait until the endpoint works again?

@mtrezza
Copy link
Member

mtrezza commented Apr 24, 2021

I'll continue in the issue thread.

@mtrezza
Copy link
Member

mtrezza commented Apr 24, 2021

After identifying the underlying issue, I suggest the following changes:

  • Use a different endpoint
    The suggested endpoint /1.1/oauth/request_token is not a valid endpoint according to the docs. It returns the expected invalid auth response but so does /1.1/oauth/blabla. Also, it is documented as a POST endpoint, but the test is for a GET endpoint. It's surprising that the test passes, likely because the Twitter API is quite graceful. Also, the correct endpoint /oauth/request_token (without the 1.1) does not require auth, it is an endpoint to authenticate, not to request a resource that requires authentication, which is what the test is about.

  • Use endpoint /1.1/account/settings.json
    It's the same endpoint the POST test uses below the GET test; the endpoint is actually a POST and GET endpoint, so we don't need to rely on two different dummy endpoints for two http methods.

  • Add a comment to the 2 tests
    To avoid confusion in the future, we should add a line to both tests (POST and GET) that these endpoints are just picked as dummies to test auth failing, for example:

    This endpoint has been chosen to make a request to an endpoint that requires OAuth which fails due to missing authentication. Any other endpoint from the Twitter API that requires OAuth can be used instead in case the currently used endpoint deprecates.

  • Clarify test purpose
    Should fail a GET request is too ambiguous. These two tests are designed to fail when trying to request a resource that requires oauth. I suggest to rename the 2 tests to:

    should fail making a GET request with invalid credentials for a resource that requires OAuth
    should fail making a POST request with invalid credentials for a resource that requires OAuth

    Also, we should change the consumer_key and consumer_secret from XXX to invalid, to make it clear that these are supposed to be invalid and therefore the tests should fail.

@dblythy
Copy link
Member Author

dblythy commented Apr 25, 2021

Thanks for the suggestions! I'll add the changes.

Copy link
Member

@mtrezza mtrezza left a comment

Choose a reason for hiding this comment

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

Formally requesting the changes so we don't merge with invalid endpoint by mistake.

spec/OAuth1.spec.js Outdated Show resolved Hide resolved
spec/OAuth1.spec.js Show resolved Hide resolved
spec/OAuth1.spec.js Show resolved Hide resolved
spec/OAuth1.spec.js Outdated Show resolved Hide resolved
@mtrezza
Copy link
Member

mtrezza commented Apr 25, 2021

This looks good! Any thing you want to add before merging?

@dblythy
Copy link
Member Author

dblythy commented Apr 25, 2021

Nope! I'm ready to merge 😊

@mtrezza mtrezza merged commit 3638b0e into parse-community:master Apr 25, 2021
@dblythy dblythy deleted the fixTwitteroauthCheck branch April 25, 2021 12:51
Copy link
Member

@mtrezza mtrezza left a comment

Choose a reason for hiding this comment

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

LGTM Thanks for tackling this so quickly!

mtrezza added a commit to mtrezza/parse-server that referenced this pull request Aug 21, 2021
mtrezza added a commit that referenced this pull request Aug 23, 2021
* bump parse 3.3.0

* Update CHANGELOG.md

* update user test (PR #7464)

* fix Twitter API oauth Error (PR #7370)

* bumped dependencies

* Revert "bumped dependencies"

This reverts commit 97ad83d.

* bump @parse/push-adapter 3.4.1

* bump jwks-rsa@1.12.3

* bump mongodb@3.6.11

* bump ws@7.5.3

* changed logging for circular obj (PR #7457)

* Update CHANGELOG.md
@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
SebC99 pushed a commit to hulab/parse-server that referenced this pull request May 29, 2022
Squashed commits:
[1306da7] Merge pull request from GHSA-23r4-5mxp-c7g5
[3a5c38d] revert to version 4.5.0 for testing
[a3483d8] fix changelog skip 4.5.1
[3c42584] 4.5.2
[97b1dca] revert to version 4.5.0 for testing
[f3133ac] Release 4.10.1 (parse-community#7508)

* bump parse 3.3.0

* Update CHANGELOG.md

* update user test (PR parse-community#7464)

* fix Twitter API oauth Error (PR parse-community#7370)

* bumped dependencies

* Revert "bumped dependencies"

This reverts commit 97ad83d.

* bump @parse/push-adapter 3.4.1

* bump jwks-rsa@1.12.3

* bump mongodb@3.6.11

* bump ws@7.5.3

* changed logging for circular obj (PR parse-community#7457)

* Update CHANGELOG.md
[7e1da90] added changelog
[0e3cae5] audit fix
[f0d5232] bumped version
[4ac4b7f] Merge pull request from GHSA-7pr3-p5fm-8r9x

* fix: LQ deletes session token

* add 4.10.4

* add changes
[ef2ec21] ci: update docker image building (parse-community#7553)

* docker

* Update docker-publish.yml

* Update docker-publish.yml
[6ae5835] Merge pull request from GHSA-xqp8-w826-hh6x

* Backport the advisory fix

* Added a 4.10.3 section to CHANGELOG
[0bfa6b7] Release 4.10.2 (parse-community#7513)

* move graphql-tag from devDependencies to dependencies (parse-community#7183)

* bump version

* Update CHANGELOG.md
[0be0b87] bump version
SebC99 pushed a commit to hulab/parse-server that referenced this pull request Nov 10, 2022
Squashed commits:
[1306da7] Merge pull request from GHSA-23r4-5mxp-c7g5
[3a5c38d] revert to version 4.5.0 for testing
[a3483d8] fix changelog skip 4.5.1
[3c42584] 4.5.2
[97b1dca] revert to version 4.5.0 for testing
[f3133ac] Release 4.10.1 (parse-community#7508)

* bump parse 3.3.0

* Update CHANGELOG.md

* update user test (PR parse-community#7464)

* fix Twitter API oauth Error (PR parse-community#7370)

* bumped dependencies

* Revert "bumped dependencies"

This reverts commit 97ad83d.

* bump @parse/push-adapter 3.4.1

* bump jwks-rsa@1.12.3

* bump mongodb@3.6.11

* bump ws@7.5.3

* changed logging for circular obj (PR parse-community#7457)

* Update CHANGELOG.md
[7e1da90] added changelog
[0e3cae5] audit fix
[f0d5232] bumped version
[4ac4b7f] Merge pull request from GHSA-7pr3-p5fm-8r9x

* fix: LQ deletes session token

* add 4.10.4

* add changes
[ef2ec21] ci: update docker image building (parse-community#7553)

* docker

* Update docker-publish.yml

* Update docker-publish.yml
[6ae5835] Merge pull request from GHSA-xqp8-w826-hh6x

* Backport the advisory fix

* Added a 4.10.3 section to CHANGELOG
[0bfa6b7] Release 4.10.2 (parse-community#7513)

* move graphql-tag from devDependencies to dependencies (parse-community#7183)

* bump version

* Update CHANGELOG.md
[0be0b87] bump version
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