Added helper method for "Bearer token" direct use

This commit is contained in:
Mauro Mugnaini 2020-08-18 12:40:53 +02:00
parent bb3728c421
commit 9dd3f3843e
1 changed files with 6 additions and 3 deletions

View File

@ -207,6 +207,10 @@ public class OpenIdConnectRESTHelper {
}
public static byte[] getUserAvatar(URL avatarURL, JWTToken token) {
return getUserAvatar(avatarURL, token != null ? token.getAccessTokenAsBearer() : null);
}
public static byte[] getUserAvatar(URL avatarURL, String authorization) {
logger.debug("Getting user avatar from URL: {}", avatarURL);
ByteArrayOutputStream buffer;
try {
@ -214,9 +218,8 @@ public class OpenIdConnectRESTHelper {
conn.setRequestMethod("GET");
conn.setDoOutput(false);
conn.setDoInput(true);
conn.setRequestProperty("Accept", "image/png, image/jpeg, image/gif");
if (token != null) {
String authorization = token.getAccessTokenAsBearer();
conn.setRequestProperty("Accept", "image/png, image/gif");
if (authorization != null) {
logger.debug("Adding authorization header as: {}", authorization);
conn.setRequestProperty("Authorization", authorization);
}