-
Notifications
You must be signed in to change notification settings - Fork 3
Return Drip's unique user ID as the UID, instead of the client id. #5
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
Open
ryenski
wants to merge
3
commits into
DripEmail:master
Choose a base branch
from
ryenski:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,7 +17,7 @@ class Drip < OmniAuth::Strategies::OAuth2 | |
| :token_url => 'https://www.getdrip.com/oauth/token' | ||
| } | ||
|
|
||
| uid { access_token.client.id } | ||
| uid { raw_info['accounts'][0]['id'] } | ||
|
|
||
| info do | ||
| { | ||
|
|
@@ -38,6 +38,10 @@ def user_info | |
| def raw_info | ||
| @raw_info ||= JSON.parse(access_token.get("/v2/accounts").body) | ||
| end | ||
|
|
||
| def callback_url | ||
| options[:redirect_uri] || (full_host + script_name + callback_path) | ||
| end | ||
|
Contributor
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. I don't know about the other change, but without this change this gem is essentially broken on omniauth-oauth2 v1.4+ |
||
| end | ||
| end | ||
| end | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,4 +26,13 @@ | |
| end | ||
| end | ||
|
|
||
| context 'uid' do | ||
|
Author
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. |
||
| before :each do | ||
| subject.stub(:raw_info) { { 'accounts' => [{ 'id' => '123' }] } } | ||
| end | ||
|
|
||
| it 'returns the id from raw_info' do | ||
| subject.uid.should eq('123') | ||
| end | ||
| end | ||
| end | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 think this should actually be a unique identifier corresponding to the user. For Drip, the user's email address is this unique identifier.
For example, it's possible that a user does not actually have access to any accounts.
Uh oh!
There was an error while loading. Please reload this page.
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.
Gotcha... but isn't it the account that we're authorizing? For example, I login to Drip using one email address, but I have two Drip accounts. If the user email is used as the identifier, how would we know which Drip account it's linking to?
This is what it looks like when I go to the authorize url:

If I authorize using my email address, and select the first Drip account, my user_info looks like this:
... and the account info looks like this:
Now if I want to connect the second Drip account (under the same user login), my user info looks the same:
... but the account info has the unique ID that I can use to identify the account:
If we use the user's email address, rather than the account ID, it would be impossible for my app to tell these two Drip accounts apart. In this case wouldn't it make more sense to use the account ID rather than the user email as the UID?
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.
Yeah, I see what you mean. I need to give this some thought. The complication is that most tokens issued these days are indeed always tied to one (and only one) active account, but there are some edge cases.
In the meantime, I would recommend making a call to the
/accountsendpoint right after obtaining the token to figure out which account the token is authorized to access. This is what most integrators do, which is probably why this issue has not be raised to date.