File tree Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -99,14 +99,25 @@ def set_token_expiration_timeout(self, value):
9999 @classmethod
100100 def from_file (cls , key_file , iam_endpoint = None , iam_channel_credentials = None ):
101101 with open (os .path .expanduser (key_file ), "r" ) as r :
102- output = json .loads (r .read ())
103- account_id = output .get ("service_account_id" , None )
102+ key = r .read ()
103+
104+ return BaseJWTCredentials .from_content (
105+ cls ,
106+ key ,
107+ iam_endpoint = iam_endpoint ,
108+ iam_channel_credentials = iam_channel_credentials
109+ )
110+
111+ @classmethod
112+ def from_content (cls , key , iam_endpoint = None , iam_channel_credentials = None ):
113+ key_json = json .loads (key )
114+ account_id = key_json .get ("service_account_id" , None )
104115 if account_id is None :
105- account_id = output .get ("user_account_id" , None )
116+ account_id = key_json .get ("user_account_id" , None )
106117 return cls (
107118 account_id ,
108- output ["id" ],
109- output ["private_key" ],
119+ key_json ["id" ],
120+ key_json ["private_key" ],
110121 iam_endpoint = iam_endpoint ,
111122 iam_channel_credentials = iam_channel_credentials ,
112123 )
You can’t perform that action at this time.
0 commit comments