Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

ApiClient and keychain adapter cleanup and fixes #667

Merged

Conversation

shana
Copy link
Member

@shana shana commented Apr 3, 2018

Dedupe code in ApiClient. Also, cache user data and avoid using the keychain username

The system keychain may have a valid token with an invalid username because every git client fills out that information slightly different and the username is not relevant for accessing the API (only the token is needed). If we encounter a mismatch, don't throw immediately (the token might be perfectly valid), but always doublecheck the github user to make sure the username of the connection matches the user that the token is associated with.

Cache the GitHubUser object in the Connection list (non serialized) so that if we fill out once and all the information matches, we can reuse it and avoid pinging the API every time. If another git client tramples all over our keychain, it's highly likely that they'll also not fill out the username information anyway, and we always grab the user from GitHub if that happens so we should be relatively safe trusting the cached GitHubUser object (it'll get thrown away whenever Unity reloads so it's also likely that we'll keep refreshing it anyways)

In the process of this, cleaned up some duplicated and uneeded code that could lead to issues later on.

…eychain username

The system keychain may have a valid token with an invalid username
because every git client fills out that information slightly different
and the username is not relevant for accessing the API
(only the token is needed). If we encounter a mismatch, don't throw
immediately (the token might be perfectly valid), but always doublecheck
the github user to make sure the username of the connection matches
the user that the token is associated with.

Cache the GitHubUser object in the Connection list (non serialized) so that
if we fill out once and all the information matches, we can reuse it and
avoid pinging the API every time. If another git client tramples all over
our keychain, it's highly likely that they'll also not fill out the username
information anyway, and we always grab the user from GitHub if that happens
so we should be relatively safe trusting the cached GitHubUser object
(it'll get thrown away whenever Unity reloads so it's also likely that we'll
keep refreshing it anyways)

In the process of this, cleaned up some duplicated and uneeded code that could
lead to issues later on.
@shana shana requested a review from StanleyGoldman April 3, 2018 14:18
@StanleyGoldman StanleyGoldman mentioned this pull request Apr 3, 2018
16 tasks
@shana shana merged commit 83e6d27 into fixes/fix-keychain-missing-exception Apr 5, 2018
@shana shana deleted the fixes/apiclient-cleanup branch April 5, 2018 19:03
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants