/** * Constructs a client ID from an explicit ID and secret. * * <p>Note: Direct use of this factory method in application code is not recommended to avoid * having secrets or values that need to be updated in source code.</p> * * @param clientId Text identifier of the Client ID. * @param clientSecret Secret to associated with the Client ID. * @return The ClientId instance. */ public static ClientId of(String clientId, String clientSecret) { return new ClientId(clientId, clientSecret); }
public ClientId build() { return new ClientId(clientId, clientSecret); } }
public ClientId build() { return new ClientId(clientId, clientSecret); } }
/** * Constructs a client ID from an explicit ID and secret. * * <p>Note: Direct use of this factory method in application code is not recommended to avoid * having secrets or values that need to be updated in source code.</p> * * @param clientId Text identifier of the Client ID. * @param clientSecret Secret to associated with the Client ID. * @return The ClientId instance. */ public static ClientId of(String clientId, String clientSecret) { return new ClientId(clientId, clientSecret); }
/** * Constructs a Client ID from JSON from a downloaded file. * * @param json The JSON from the downloaded file. * @return the ClientId instance based on the JSON. * @throws IOException The JSON could not be parsed. */ public static ClientId fromJson(Map<String, Object> json) throws IOException { Object rawDetail = null; rawDetail = json.get(FIELD_TYPE_INSTALLED); if (rawDetail == null) { rawDetail = json.get(FIELD_TYPE_WEB); } if (rawDetail == null || !(rawDetail instanceof Map<?,?>)) { throw new IOException("Unable to parse Client ID JSON. Expecting top-level field '" + FIELD_TYPE_WEB + "' or '" + FIELD_TYPE_INSTALLED + "' of collection type"); } @SuppressWarnings("unchecked") Map<String, Object> detail = (Map<String,Object>)rawDetail; String clientId = OAuth2Utils.validateString(detail, FIELD_CLIENT_ID, JSON_PARSE_ERROR); if (clientId == null || clientId.length() == 0) { throw new IOException("Unable to parse ClientId. Field '" + FIELD_CLIENT_ID + "' is required."); } String clientSecret = OAuth2Utils.validateOptionalString( detail, FIELD_CLIENT_SECRET, JSON_PARSE_ERROR); return new ClientId(clientId, clientSecret); }
/** * Constructs a Client ID from JSON from a downloaded file. * * @param json The JSON from the downloaded file. * @return the ClientId instance based on the JSON. * @throws IOException The JSON could not be parsed. */ public static ClientId fromJson(Map<String, Object> json) throws IOException { Object rawDetail = null; rawDetail = json.get(FIELD_TYPE_INSTALLED); if (rawDetail == null) { rawDetail = json.get(FIELD_TYPE_WEB); } if (rawDetail == null || !(rawDetail instanceof Map<?,?>)) { throw new IOException("Unable to parse Client ID JSON. Expecting top-level field '" + FIELD_TYPE_WEB + "' or '" + FIELD_TYPE_INSTALLED + "' of collection type"); } @SuppressWarnings("unchecked") Map<String, Object> detail = (Map<String,Object>)rawDetail; String clientId = OAuth2Utils.validateString(detail, FIELD_CLIENT_ID, JSON_PARSE_ERROR); if (clientId == null || clientId.length() == 0) { throw new IOException("Unable to parse ClientId. Field '" + FIELD_CLIENT_ID + "' is required."); } String clientSecret = OAuth2Utils.validateOptionalString( detail, FIELD_CLIENT_SECRET, JSON_PARSE_ERROR); return new ClientId(clientId, clientSecret); }