Added helper method for "Bearer token" direct use
This commit is contained in:
parent
bb3728c421
commit
9dd3f3843e
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue