-
Notifications
You must be signed in to change notification settings - Fork 312
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a fallback to load creds from legacy JSON file if normal load fails
- Loading branch information
Showing
5 changed files
with
130 additions
and
69 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
{"access_token": "d3adb33f", "client_id": "someclient.apps.googleusercontent.com", "client_secret": "SECRET-secret-SECRET", "refresh_token": "SOME-REFRESH-TOKEN", "token_expiry": "2099-01-01T00:00:00Z", "token_uri": "https://oauth2.googleapis.com/token", "user_agent": "gcalcli/v4.3.0", "revoke_uri": "https://oauth2.googleapis.com/revoke", "id_token": null, "id_token_jwt": null, "token_response": {"access_token": "some.ACCESS-tOKeN", "expires_in": 3599, "refresh_token": "SOME-REFRESH-TOKEN", "scope": "https://www.googleapis.com/auth/calendar", "token_type": "Bearer"}, "scopes": ["https://www.googleapis.com/auth/calendar"], "token_info_uri": "https://oauth2.googleapis.com/tokeninfo", "invalid": false, "_class": "OAuth2Credentials", "_module": "oauth2client.client"} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import pathlib | ||
import shutil | ||
|
||
try: | ||
import cPickle as pickle # type: ignore | ||
except Exception: | ||
import pickle | ||
|
||
import googleapiclient.discovery | ||
|
||
TEST_DATA_DIR = pathlib.Path(__file__).parent / 'data' | ||
|
||
|
||
def test_legacy_certs(tmpdir, gcali_patches, patched_google_reauth): | ||
tmpdir = pathlib.Path(tmpdir) | ||
oauth_filepath = tmpdir / 'oauth' | ||
shutil.copy(TEST_DATA_DIR / 'legacy_oauth_creds.json', oauth_filepath) | ||
gcal = gcali_patches.GCalI(config_folder=tmpdir, refresh_cache=False) | ||
assert isinstance( | ||
gcal.get_cal_service(), googleapiclient.discovery.Resource | ||
) | ||
with open(oauth_filepath, 'rb') as gcalcli_oauth: | ||
try: | ||
pickle.load(gcalcli_oauth) | ||
except Exception as e: | ||
raise AssertionError( | ||
f"Couldn't load oauth file as updated pickle format: {e}" | ||
) |