Skip to content

Use the id of the account instead of the application id #3108

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

Merged
merged 3 commits into from
Nov 25, 2016
Merged

Use the id of the account instead of the application id #3108

merged 3 commits into from
Nov 25, 2016

Conversation

jonas-db
Copy link

Fix for issue: #3106

@@ -12,7 +12,7 @@ function validateAuthData(authData, options) {
client.auth_token_secret = authData.auth_token_secret;

return client.get("/1.1/account/verify_credentials.json").then((data) => {
if (data && data.id == authData.id) {
if (data && data.id_str == authData.user_id) {
Copy link
Contributor

Choose a reason for hiding this comment

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

using authData.user_id is a breaking change, not sure why we should change that here.

Copy link
Author

@jonas-db jonas-db Nov 24, 2016

Choose a reason for hiding this comment

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

The response from twitter does include the data.id, but it is not always correct: https://dev.twitter.com/overview/api/twitter-ids-json-and-snowflake. This is a possible way to solve the problem as the response does include the id_strwhich is the account id (which is included when requesting a token).

The naming of authData.user_id is debatable since this is returned from hellojs (it can just stay id)

Copy link
Contributor

Choose a reason for hiding this comment

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

I guest that, my point is why change authData.id to authData.user_id

Copy link
Author

Choose a reason for hiding this comment

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

See my edits to make it clear. It might as well stay id (hellojs returns user_id)

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah but the parse SDK uses id for the twitter authData user ID so you can't change that...

Copy link
Author

Choose a reason for hiding this comment

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

I agree, it was a quick fix without thinking about the consequences. Can I somehow edit this or do i need to create a new pull request?

@facebook-github-bot
Copy link

@jonas-db updated the pull request - view changes

@flovilmart
Copy link
Contributor

@@ -12,7 +12,7 @@ function validateAuthData(authData, options) {
client.auth_token_secret = authData.auth_token_secret;

return client.get("/1.1/account/verify_credentials.json").then((data) => {
if (data && data.id == authData.id) {
if (data && data.id_str == authData.id) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Given the twitter doc, where both id and id_str are provided, authData.id is not guaranteed to be neither a string nor a number. Given that, we should either type check, or use if (data && data.id_str == ''+authData.id) to make sure we're comparing the same types

Copy link
Author

@jonas-db jonas-db Nov 24, 2016

Choose a reason for hiding this comment

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

Indeed, I will wait for further instructions because I guess it is not up to me to decide that :D

I have tested my implementation again and I do have indeed a real twitter account where id and id_str differs, which makes it fails. Changing it to data.id_str works.

Copy link
Contributor

Choose a reason for hiding this comment

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

id and id_str differs

Can you expand on that? How would they differ?

Copy link
Author

Choose a reason for hiding this comment

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

Consider the twitter link I posted earlier, which explains why they can be different from each other

Copy link
Contributor

Choose a reason for hiding this comment

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

Which link?

Copy link
Contributor

Choose a reason for hiding this comment

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

Found it!

@flovilmart
Copy link
Contributor

@jonas-db can you force the authData.id to be a string by using? ''+authData.id We'll be able to merge after that.

@facebook-github-bot
Copy link

@jonas-db updated the pull request - view changes

@flovilmart
Copy link
Contributor

@jonas-db Many thanks for the fix!

@flovilmart flovilmart merged commit c83a787 into parse-community:master Nov 25, 2016
rsouzas pushed a commit to back4app/parse-server that referenced this pull request Dec 3, 2016
…ity#3108)

* Use the id of the account instead of the application id

Fix for issue: parse-community#3106

* Update twitter.js

* Update twitter.js
Jcarlosjunior pushed a commit to back4app/parse-server that referenced this pull request Dec 13, 2016
…ity#3108)

* Use the id of the account instead of the application id

Fix for issue: parse-community#3106

* Update twitter.js

* Update twitter.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants