File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change
1
+ import os
2
+ from google .oauth2 import service_account
3
+ from google .auth .transport .requests import Request
4
+
5
+ def get_token_from_user_file (user_file_path ):
6
+ SCOPES = ["https://www.googleapis.com/auth/spreadsheets" ]
7
+
8
+ credentials = service_account .Credentials .from_service_account_file (
9
+ user_file_path ,
10
+ scopes = SCOPES
11
+ )
12
+
13
+ request = Request ()
14
+ credentials .refresh (request )
15
+ return credentials .token
16
+
17
+ key_file_path = "credentials.json"
18
+ token = get_token_from_user_file (key_file_path )
19
+
20
+ env_file = os .getenv ('GITHUB_ENV' )
21
+
22
+ with open (env_file , "a" ) as myfile :
23
+ # Set the token as an env var for some tests
24
+ myfile .write (f"TOKEN={ token } \n " )
25
+ # Set the key_file filepath as an env var for other tests
26
+ myfile .write (f"KEY_FILE_PATH={ key_file_path } " )
27
+
You can’t perform that action at this time.
0 commit comments