When usign the RestFB SDK and a wrong or expired token when authenticating, the application crashes. It can't be handled by a try/catch block. Does anyone know how to fix this?
public static void main(String[] args) {
FacebookClient facebookClient = null;
String _pageAccessToken = "0000";
if (!"".equals(_pageAccessToken)) {
try{
facebookClient = new DefaultFacebookClient(_pageAccessToken, Version.VERSION_18_0);
}catch (FacebookOAuthException ex1) {
String msg = "Authentication error ...";
}catch (Exception ex2){
String msg= "Authentication error ...";
}catch (Throwable th1){
String msg= "Authentication error ...";
}
}
}
Message:
Exception in thread "main" com.restfb.exception.FacebookOAuthException: Received Facebook error response of type OAuthException: The access token could not be decrypted (code 190, subcode null) 'null - null'
at com.restfb.exception.generator.DefaultFacebookExceptionGenerator$DefaultGraphFacebookExceptionMapper.exceptionForTypeAndMessage(DefaultFacebookExceptionGenerator.java:181)
at com.restfb.exception.generator.DefaultFacebookExceptionGenerator.throwFacebookResponseStatusExceptionIfNecessary(DefaultFacebookExceptionGenerator.java:65)
at com.restfb.DefaultFacebookClient.makeRequestAndProcessResponse(DefaultFacebookClient.java:850)
at com.restfb.DefaultFacebookClient.makeRequest(DefaultFacebookClient.java:766)
at com.restfb.DefaultFacebookClient.makeRequest(DefaultFacebookClient.java:722)
at com.restfb.DefaultFacebookClient.publish(DefaultFacebookClient.java:353)
at com.restfb.DefaultFacebookClient.publish(DefaultFacebookClient.java:373)
pom.xml
<dependencies>
<dependency>
<groupId>com.restfb</groupId>
<artifactId>restfb</artifactId>
<version>2023.15.0</version>
</dependency>
</dependencies>
How to prevent the app from crashing?