-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Request Twitter email #452
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
Changes from 1 commit
c40fa42
d81b5f9
7af8e9b
4dec62e
7d7c582
ed4b11b
bff53a5
24a2628
086e5dd
639b9d1
f537d1b
6695453
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,8 +60,18 @@ public void startLogin(Activity activity) { | |
} | ||
|
||
@Override | ||
public void success(Result<TwitterSession> result) { | ||
mCallbackObject.onSuccess(createIdpResponse(result.data)); | ||
public void success(final Result<TwitterSession> sessionResult) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Twitter caused a leak by storing our callback in a result receiver:
and their Anyway, I dug through the source code and ripped Twitter's GET request so that we can handle that stuff ourselves. Now if we didn't get an email, we know whether or not the dev hasn't requested the email permission in the twitter dashboard or if the Twitter user just doesn't have an email. @samtstern Since we now have control over what's going on, we can decide what to do in the two failure cases. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @SUPERCILEX I appreciate all the investigation but I have a few reservations about this approach:
As for the leak, I think we can work around that ourselves by making the callback a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @samtstern Whoa, you just blew my mind! The main reason I didn't want to use |
||
mTwitterAuthClient.requestEmail(sessionResult.data, new Callback<String>() { | ||
@Override | ||
public void success(Result<String> result) { | ||
mCallbackObject.onSuccess(createIdpResponse(sessionResult.data, result.data)); | ||
} | ||
|
||
@Override | ||
public void failure(TwitterException exception) { | ||
TwitterProvider.this.failure(exception); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a problem:
It will be confusing to the user if they press authorize and the sign in just fails unexpectedly because they didn't give Twitter an email. The only place we need to display a message is in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a problem ... I need to look into this and ask someone who knows more than I do :-) |
||
} | ||
}); | ||
} | ||
|
||
@Override | ||
|
@@ -70,10 +80,10 @@ public void failure(TwitterException exception) { | |
mCallbackObject.onFailure(new Bundle()); | ||
} | ||
|
||
private IdpResponse createIdpResponse(TwitterSession twitterSession) { | ||
private IdpResponse createIdpResponse(TwitterSession twitterSession, String email) { | ||
return new IdpResponse( | ||
TwitterAuthProvider.PROVIDER_ID, | ||
null, | ||
email, | ||
twitterSession.getAuthToken().token, | ||
twitterSession.getAuthToken().secret); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this should be nullable: we always know the email address and provider id and since having it be nullable caused a crash, I made it @nonnull.