File tree Expand file tree Collapse file tree 2 files changed +11
-15
lines changed
intercom-java/src/main/java/io/intercom/api Expand file tree Collapse file tree 2 files changed +11
-15
lines changed Original file line number Diff line number Diff line change @@ -228,21 +228,18 @@ private HttpURLConnection prepareConnection(HttpURLConnection conn) {
228228
229229 private Map <String , String > createAuthorizationHeaders () {
230230 switch (Intercom .getAuthKeyType ()) {
231- case BEARER :
232- headers .put ("Authorization" , "Bearer " + Intercom .getApiKey ());
233- break ;
234231 case API_KEY :
235- headers .put ("Authorization" , "Basic " + Base64 . encodeBase64String ( generateAuthString (Intercom .getAppID (),Intercom .getApiKey ()). getBytes ()));
232+ headers .put ("Authorization" , "Basic " + generateAuthString (Intercom .getAppID (),Intercom .getApiKey ()));
236233 break ;
237- case PERSONAL_ACCESS_TOKEN :
238- headers .put ("Authorization" , "Basic " + Base64 . encodeBase64String ( generateAuthString (Intercom .getPersonalAccessToken (),"" ). getBytes () ));
234+ case TOKEN :
235+ headers .put ("Authorization" , "Basic " + generateAuthString (Intercom .getToken (),"" ));
239236 break ;
240237 }
241238 return headers ;
242239 }
243240
244241 private String generateAuthString (String username , String password ) {
245- return username + ":" + password ;
242+ return Base64 . encodeBase64String (( username + ":" + password ). getBytes ()) ;
246243 }
247244
248245 private Map <String , String > createHeaders () {
Original file line number Diff line number Diff line change @@ -12,8 +12,7 @@ public class Intercom {
1212
1313 enum AuthKeyType {
1414 API_KEY ,
15- BEARER ,
16- PERSONAL_ACCESS_TOKEN
15+ TOKEN
1716 }
1817
1918 private static final String VERSION = "2.1.0" ;
@@ -22,7 +21,7 @@ enum AuthKeyType {
2221
2322 private static volatile String apiKey ;
2423
25- private static volatile String personalAccessToken ;
24+ private static volatile String token ;
2625
2726 private static volatile String appID ;
2827
@@ -80,9 +79,9 @@ public static void setAppID(String appID) {
8079 Intercom .appID = appID ;
8180 }
8281
83- public static void setPersonalAccessToken (String personalAccessToken ) {
84- authKeyType = AuthKeyType .PERSONAL_ACCESS_TOKEN ;
85- Intercom .personalAccessToken = personalAccessToken ;
82+ public static void setToken (String token ) {
83+ authKeyType = AuthKeyType .TOKEN ;
84+ Intercom .token = token ;
8685 }
8786
8887 public static String getApiKey () {
@@ -106,8 +105,8 @@ static AuthKeyType getAuthKeyType() {
106105 return authKeyType ;
107106 }
108107
109- public static String getPersonalAccessToken () {
110- return personalAccessToken ;
108+ public static String getToken () {
109+ return token ;
111110 }
112111
113112
You can’t perform that action at this time.
0 commit comments