openid / AppAuth-Android

Android client SDK for communicating with OAuth 2.0 and OpenID Connect providers.
https://openid.github.io/AppAuth-Android
Apache License 2.0
2.82k stars 881 forks source link

Retrieving correlation id on refreshToken exception #770

Open victorlsn opened 2 years ago

victorlsn commented 2 years ago

Configuration

Description

Hi, I'm trying to log exceptions when refreshing tokens, and in such situation I'd like to have access to the correlation id (sent by server as part of the response), but I see no option to retrieve headers when receiving an AuthorizationException via performTokenRequest. Do you have some suggestion on how to achieve this?

Thanks in advance!

agologan commented 2 years ago

There is a way though I don't know how easy it is to do today. The way it was designed to do this is by providing ConnectionBuilder On paper at least, you could create a HttpUrlConnection proxy class that would make easy to log your necessary information.

In the past I've done this via OkHttp's OkUrlFactory which would create the request and added an interceptor HTTP Logging Interceptor to the client. While OkUrlFactory was removed you can still get it back via https://gist.github.com/swankjesse/dd91c0a8854e1559b00f5fc9c7bfae70 .