-
Notifications
You must be signed in to change notification settings - Fork 314
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve auth setup experience with more self-contained explanations/l…
…inks
- Loading branch information
Showing
5 changed files
with
76 additions
and
42 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
__program__ = 'gcalcli' | ||
__version__ = 'v4.3.0' | ||
__author__ = 'Eric Davis, Brian Hartvigsen, Joshua Crowgey' | ||
__API_CLIENT_ID__ = '232867676714.apps.googleusercontent.com' | ||
__API_CLIENT_SECRET__ = '3tZSxItw6_VnZMezQwC8lUqy' |
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,26 @@ | ||
from google.auth.transport.requests import Request | ||
from google_auth_oauthlib.flow import InstalledAppFlow | ||
|
||
|
||
def authenticate(client_id: str, client_secret: str): | ||
flow = InstalledAppFlow.from_client_config( | ||
client_config={ | ||
"installed": { | ||
"client_id": client_id, | ||
"client_secret": client_secret, | ||
"auth_uri": "https://accounts.google.com/o/oauth2/auth", | ||
"token_uri": "https://oauth2.googleapis.com/token", | ||
"auth_provider_x509_cert_url": | ||
"https://www.googleapis.com/oauth2/v1/certs", | ||
"redirect_uris": ["http://localhost"], | ||
} | ||
}, | ||
scopes=["https://www.googleapis.com/auth/calendar"], | ||
) | ||
credentials = flow.run_local_server(open_browser=False) | ||
return credentials | ||
|
||
|
||
def refresh_if_expired(credentials) -> None: | ||
if credentials.expired: | ||
credentials.refresh(Request()) |
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