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):
99
99
@classmethod
100
100
def from_file (cls , key_file , iam_endpoint = None , iam_channel_credentials = None ):
101
101
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 )
104
115
if account_id is None :
105
- account_id = output .get ("user_account_id" , None )
116
+ account_id = key_json .get ("user_account_id" , None )
106
117
return cls (
107
118
account_id ,
108
- output ["id" ],
109
- output ["private_key" ],
119
+ key_json ["id" ],
120
+ key_json ["private_key" ],
110
121
iam_endpoint = iam_endpoint ,
111
122
iam_channel_credentials = iam_channel_credentials ,
112
123
)
You can’t perform that action at this time.
0 commit comments