private TokenInfo parseVerifyToken(String json){
  if (json == null) {
    LOGGER.warning("Error parsing verify token result (null)");
    return null;
  }
  try {
    JSONParser parser=new JSONParser();
    JSONObject root=(JSONObject)parser.parse(json);
    JSONObject token=(JSONObject)root.get("token");
    if (token == null) {
      return null;
    }
    boolean valid=(Boolean)token.get("valid");
    if (!valid) {
      return new TokenInfo();
    }
    String username=(String)token.get("user_name");
    JSONObject authorization=(JSONObject)token.get("authorization");
    JSONArray scopes=(JSONArray)authorization.get("scopes");
    boolean allowCommercials=scopes.contains("channel_commercial");
    boolean allowEditor=scopes.contains("channel_editor");
    boolean chatAccess=scopes.contains("chat_login");
    boolean userAccess=scopes.contains("user_read");
    boolean readSubscriptions=scopes.contains("channel_subscriptions");
    boolean userEditFollows=scopes.contains("user_follows_edit");
    return new TokenInfo(username,chatAccess,allowEditor,allowCommercials,userAccess,readSubscriptions,userEditFollows);
  }
 catch (  ParseException e) {
    return null;
  }
}

private TokenInfo parseVerifyToken ( String json ) { if ( json == null ) { LOGGER . warning ( "Error parsing verify token result (null)" ) ; return null ; } try { JSONParser parser = new JSONParser ( ) ; JSONObject root = ( JSONObject ) parser . parse ( json ) ; JSONObject token = ( JSONObject ) root . get ( "token" ) ; if ( token == null ) { return null ; } boolean valid = ( Boolean ) token . get ( "valid" ) ; if ( ! valid ) { return new TokenInfo ( ) ; } String username = ( String ) token . get ( "user_name" ) ; JSONObject authorization = ( JSONObject ) token . get ( "authorization" ) ; JSONArray scopes = ( JSONArray ) authorization . get ( "scopes" ) ; boolean allowCommercials = scopes . contains ( "channel_commercial" ) ; boolean allowEditor = scopes . contains ( "channel_editor" ) ; boolean chatAccess = scopes . contains ( "chat_login" ) ; boolean userAccess = scopes . contains ( "user_read" ) ; boolean readSubscriptions = scopes . contains ( "channel_subscriptions" ) ; boolean userEditFollows = scopes . contains ( "user_follows_edit" ) ; return new TokenInfo ( username , chatAccess , allowEditor , allowCommercials , userAccess , readSubscriptions , userEditFollows ) ; } catch ( ParseException e ) { return null ; } }
parses the json returned from the twitchapi that contains the token info into a tokeninfo object .
