public static String base64UrlEncode(byte[] arg){
  String s=Base64.encodeToString(arg,0);
  s=s.split("=")[0];
  s=s.replace('+','-');
  s=s.replace('/','_');
  return s;
}

public static String base64UrlEncode ( byte [ ] arg ) { String s = Base64 . encodeToString ( arg , 0 ) ; s = s . split ( "=" ) [ 0 ] ; s = s . replace ( '+' , '-' ) ; s = s . replace ( '/' , '_' ) ; return s ; }
encode a byte array into a string , while trimming off the last characters , as required by the amazon token server see : http : / / brockallen . com / 2014 / 10 / 17 / base64url - encoding /
