1515import com .nimbusds .oauth2 .sdk .http .HTTPRequest ;
1616import com .nimbusds .oauth2 .sdk .http .HTTPResponse ;
1717import com .nimbusds .oauth2 .sdk .token .AccessToken ;
18- import com .nimbusds .oauth2 .sdk .tokenexchange .TokenExchangeGrant ;
1918import io .grpc .CallOptions ;
2019import io .grpc .Channel ;
2120import io .grpc .ClientCall ;
2221import io .grpc .ClientInterceptor ;
2322import io .grpc .ForwardingClientCall ;
2423import io .grpc .Metadata ;
2524import io .grpc .MethodDescriptor ;
25+ import org .slf4j .Logger ;
26+ import org .slf4j .LoggerFactory ;
2627
2728import java .net .URI ;
2829import java .net .URISyntaxException ;
@@ -40,6 +41,9 @@ class GRPCAuthInterceptor implements ClientInterceptor {
4041 private final RSAKey rsaKey ;
4142 private final URI tokenEndpointURI ;
4243
44+ private static final Logger logger = LoggerFactory .getLogger (GRPCAuthInterceptor .class );
45+
46+
4347 /**
4448 * Constructs a new GRPCAuthInterceptor with the specified client authentication and RSA key.
4549 *
@@ -101,6 +105,8 @@ private synchronized AccessToken getToken() {
101105 // If the token is expired or initially null, get a new token
102106 if (token == null || isTokenExpired ()) {
103107
108+ logger .trace ("The current access token is expired or empty, getting a new one" );
109+
104110 // Construct the client credentials grant
105111 AuthorizationGrant clientGrant = new ClientCredentialsGrant ();
106112
@@ -124,9 +130,17 @@ private synchronized AccessToken getToken() {
124130 throw new RuntimeException ("Token request failed: " + error );
125131 }
126132
127- this .token = tokenResponse .toSuccessResponse ().getTokens ().getAccessToken ();
128- // DPoPAccessToken dPoPAccessToken = tokens.getDPoPAccessToken();
129133
134+ var tokens = tokenResponse .toSuccessResponse ().getTokens ();
135+ if (tokens .getDPoPAccessToken () != null ) {
136+ logger .trace ("retrieved a new DPoP access token" );
137+ } else if (tokens .getAccessToken () != null ) {
138+ logger .trace ("retrieved a new access token" );
139+ } else {
140+ logger .trace ("got an access token of unknown type" );
141+ }
142+
143+ this .token = tokens .getAccessToken ();
130144
131145 if (token .getLifetime () != 0 ) {
132146 // Need some type of leeway but not sure whats best
0 commit comments