File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -99,14 +99,22 @@ 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 , key , iam_endpoint = iam_endpoint , iam_channel_credentials = iam_channel_credentials
106
+ )
107
+
108
+ @classmethod
109
+ def from_content (cls , key , iam_endpoint = None , iam_channel_credentials = None ):
110
+ key_json = json .loads (key )
111
+ account_id = key_json .get ("service_account_id" , None )
104
112
if account_id is None :
105
- account_id = output .get ("user_account_id" , None )
113
+ account_id = key_json .get ("user_account_id" , None )
106
114
return cls (
107
115
account_id ,
108
- output ["id" ],
109
- output ["private_key" ],
116
+ key_json ["id" ],
117
+ key_json ["private_key" ],
110
118
iam_endpoint = iam_endpoint ,
111
119
iam_channel_credentials = iam_channel_credentials ,
112
120
)
You can’t perform that action at this time.
0 commit comments