@@ -15,7 +15,7 @@ use tokio::sync::RwLock;
15
15
use tracing:: { debug, instrument, Level } ;
16
16
use url:: form_urlencoded;
17
17
18
- use crate :: types:: { ApplicationCredentials , HttpClient , Signer , Token } ;
18
+ use crate :: types:: { HttpClient , ServiceAccountKey , Signer , Token } ;
19
19
use crate :: { Error , TokenProvider } ;
20
20
21
21
/// A custom service account containing credentials
@@ -27,7 +27,7 @@ use crate::{Error, TokenProvider};
27
27
#[ derive( Debug ) ]
28
28
pub struct CustomServiceAccount {
29
29
client : HttpClient ,
30
- credentials : ApplicationCredentials ,
30
+ credentials : ServiceAccountKey ,
31
31
signer : Signer ,
32
32
tokens : RwLock < HashMap < Vec < String > , Arc < Token > > > ,
33
33
subject : Option < String > ,
@@ -37,20 +37,20 @@ impl CustomServiceAccount {
37
37
/// Check `GOOGLE_APPLICATION_CREDENTIALS` environment variable for a path to JSON credentials
38
38
pub fn from_env ( ) -> Result < Option < Self > , Error > {
39
39
debug ! ( "check for GOOGLE_APPLICATION_CREDENTIALS env var" ) ;
40
- match ApplicationCredentials :: from_env ( ) ? {
40
+ match ServiceAccountKey :: from_env ( ) ? {
41
41
Some ( credentials) => Self :: new ( credentials, HttpClient :: new ( ) ?) . map ( Some ) ,
42
42
None => Ok ( None ) ,
43
43
}
44
44
}
45
45
46
46
/// Read service account credentials from the given JSON file
47
47
pub fn from_file < T : AsRef < Path > > ( path : T ) -> Result < Self , Error > {
48
- Self :: new ( ApplicationCredentials :: from_file ( path) ?, HttpClient :: new ( ) ?)
48
+ Self :: new ( ServiceAccountKey :: from_file ( path) ?, HttpClient :: new ( ) ?)
49
49
}
50
50
51
51
/// Read service account credentials from the given JSON string
52
52
pub fn from_json ( s : & str ) -> Result < Self , Error > {
53
- Self :: new ( ApplicationCredentials :: from_str ( s) ?, HttpClient :: new ( ) ?)
53
+ Self :: new ( ServiceAccountKey :: from_str ( s) ?, HttpClient :: new ( ) ?)
54
54
}
55
55
56
56
/// Set the `subject` to impersonate a user
@@ -59,7 +59,7 @@ impl CustomServiceAccount {
59
59
self
60
60
}
61
61
62
- fn new ( credentials : ApplicationCredentials , client : HttpClient ) -> Result < Self , Error > {
62
+ fn new ( credentials : ServiceAccountKey , client : HttpClient ) -> Result < Self , Error > {
63
63
debug ! ( project = ?credentials. project_id, email = credentials. client_email, "found credentials" ) ;
64
64
Ok ( Self {
65
65
client,
@@ -156,11 +156,7 @@ pub(crate) struct Claims<'a> {
156
156
}
157
157
158
158
impl < ' a > Claims < ' a > {
159
- pub ( crate ) fn new (
160
- key : & ' a ApplicationCredentials ,
161
- scopes : & [ & str ] ,
162
- sub : Option < & ' a str > ,
163
- ) -> Self {
159
+ pub ( crate ) fn new ( key : & ' a ServiceAccountKey , scopes : & [ & str ] , sub : Option < & ' a str > ) -> Self {
164
160
let mut scope = String :: with_capacity ( 16 ) ;
165
161
for ( i, s) in scopes. iter ( ) . enumerate ( ) {
166
162
if i != 0 {
0 commit comments