@@ -15,7 +15,7 @@ use tokio::sync::RwLock;
1515use tracing:: { debug, instrument, Level } ;
1616use url:: form_urlencoded;
1717
18- use crate :: types:: { ApplicationCredentials , HttpClient , Signer , Token } ;
18+ use crate :: types:: { HttpClient , ServiceAccountKey , Signer , Token } ;
1919use crate :: { Error , TokenProvider } ;
2020
2121/// A custom service account containing credentials
@@ -27,7 +27,7 @@ use crate::{Error, TokenProvider};
2727#[ derive( Debug ) ]
2828pub struct CustomServiceAccount {
2929 client : HttpClient ,
30- credentials : ApplicationCredentials ,
30+ credentials : ServiceAccountKey ,
3131 signer : Signer ,
3232 tokens : RwLock < HashMap < Vec < String > , Arc < Token > > > ,
3333 subject : Option < String > ,
@@ -37,20 +37,20 @@ impl CustomServiceAccount {
3737 /// Check `GOOGLE_APPLICATION_CREDENTIALS` environment variable for a path to JSON credentials
3838 pub fn from_env ( ) -> Result < Option < Self > , Error > {
3939 debug ! ( "check for GOOGLE_APPLICATION_CREDENTIALS env var" ) ;
40- match ApplicationCredentials :: from_env ( ) ? {
40+ match ServiceAccountKey :: from_env ( ) ? {
4141 Some ( credentials) => Self :: new ( credentials, HttpClient :: new ( ) ?) . map ( Some ) ,
4242 None => Ok ( None ) ,
4343 }
4444 }
4545
4646 /// Read service account credentials from the given JSON file
4747 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 ( ) ?)
4949 }
5050
5151 /// Read service account credentials from the given JSON string
5252 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 ( ) ?)
5454 }
5555
5656 /// Set the `subject` to impersonate a user
@@ -59,7 +59,7 @@ impl CustomServiceAccount {
5959 self
6060 }
6161
62- fn new ( credentials : ApplicationCredentials , client : HttpClient ) -> Result < Self , Error > {
62+ fn new ( credentials : ServiceAccountKey , client : HttpClient ) -> Result < Self , Error > {
6363 debug ! ( project = ?credentials. project_id, email = credentials. client_email, "found credentials" ) ;
6464 Ok ( Self {
6565 client,
@@ -156,11 +156,7 @@ pub(crate) struct Claims<'a> {
156156}
157157
158158impl < ' 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 {
164160 let mut scope = String :: with_capacity ( 16 ) ;
165161 for ( i, s) in scopes. iter ( ) . enumerate ( ) {
166162 if i != 0 {
0 commit comments