class GAuthToken {

  public static GAuthToken tryParseFromString(String rawToken) {
    if (!rawToken.startsWith(TOKEN_PREFIX)) {
      return null;
    }

    String gauthToken = rawToken.substring(TOKEN_PREFIX.length());
    try {
      Map<String, Object> tokenMap = JsonMapper.parseJson(gauthToken);
      String token = (String) tokenMap.get(TOKEN_KEY);
      @SuppressWarnings("unchecked")
      Map<String, Object> auth = (Map<String, Object>) tokenMap.get(AUTH_KEY);
      return new GAuthToken(token, auth);
    } catch (IOException e) {
      throw new RuntimeException("Failed to parse gauth token", e);
    }
  }

  public  GAuthToken(String token, Map<String, Object> auth);

}