-
Notifications
You must be signed in to change notification settings - Fork 94
Open
Description
When calling twitter v2 api by twitterApi.users().findMyUser() when user's accessToken, the user's twitter account is suspened, but the api does not deserialize the ApiException properly.
TwitterCredentialsOAuth2 oAuth2Credential = new TwitterCredentialsOAuth2("devClientId", "", request.getAccessToken(), "", false);
TwitterApi twitterApi = new TwitterApi(oAuth2Credential);
Get2UsersMeResponse response = twitterApi.users()
.findMyUser()
.userFields(userFields)
.tweetFields(tweetFields)
.expansions(expansions)
.execute();
then, it catches the Exception
com.google.gson.JsonSyntaxException: java.io.IOException: Failed deserialization for ProblemOrError: 0 classes match result, expected 1. Detailed failure message for oneOf schemas: [Deserialization for Error failed with `The required field `code` is not found in the JSON string: {"detail":"The user used for authentication is suspended","title":"Forbidden","status":403,"type":"https://api.twitter.com/2/problems/user-suspended"}`., Deserialization for Problem failed with `The value of the `type` field `https://api.twitter.com/2/problems/user-suspended` does not match any key defined in the discriminator's mapping.`.]. JSON: {"detail":"The user used for authentication is suspended","title":"Forbidden","status":403,"type":"https://api.twitter.com/2/problems/user-suspended"}
It does not handle the type of Problem or Error properly.
Metadata
Metadata
Assignees
Labels
No labels