generated from cds-snc/project-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add the code for generating the google pickle string (#326)
- Loading branch information
1 parent
2ad741a
commit ca654bb
Showing
3 changed files
with
27 additions
and
1 deletion.
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 |
---|---|---|
|
@@ -215,4 +215,7 @@ token.json | |
auto.tfvars | ||
*.db | ||
|
||
geodb | ||
geodb | ||
|
||
|
||
credentials.json |
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,19 @@ | ||
import base64 | ||
import pickle | ||
from google_auth_oauthlib.flow import InstalledAppFlow | ||
|
||
SCOPES = [ | ||
"https://www.googleapis.com/auth/drive.file", | ||
"https://www.googleapis.com/auth/docs", | ||
"https://www.googleapis.com/auth/spreadsheets", | ||
] | ||
def main(): | ||
flow = InstalledAppFlow.from_client_secrets_file('credentials.json', SCOPES) | ||
creds = flow.run_local_server(port=8081) | ||
if not creds or not creds.valid: | ||
print("There is issue with credentials. Please check.") | ||
exit(0) | ||
print("\n\nCopy pickle string which is present in single quotes and save. Paste it during installation GWorkspace Function App:\n\n{}".format(base64.b64encode(pickle.dumps(creds)))) | ||
|
||
if __name__ == '__main__': | ||
main() |
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,4 @@ | ||
|
||
google-api-python-client | ||
google-auth-httplib2 | ||
google-auth-oauthlib |