Please check as follows:
- Check your access_token: obtain the access_token and print it.
- When referencing Base64, refer to
import org.apache.commons.codec.binary.Base64;
- Add to the header correctly:
* Construct an Authorization field in the request header.
*
* @param appAt App-level access token.
* @return headers Return the request header.
*/
public static Map<String, String> buildAuthorization(String appAt) {
String oriString = MessageFormat.format("APPAT:{0}", appAt);
String authorization =
MessageFormat.format("Basic {0}", Base64.encodeBase64String(oriString.getBytes(StandardCharsets.UTF_8)));
Map<String, String> headers = new HashMap<>();
headers.put("Authorization", authorization);
headers.put("Content-Type", "application/json; charset=UTF-8");
return headers;
}
/**
For more details, see docs.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…