/** Validates the properties for the Ad Manager session. */ private void validate() throws ValidationException { // Check for at least one authentication mechanism. if (this.oAuth2Credential == null) { throw new ValidationException("OAuth2 authentication must be used.", ""); } // Check that application name is not empty or the default. if (Strings.nullToEmpty(applicationName).trim().isEmpty() || applicationName.contains(DEFAULT_APPLICATION_NAME)) { throw new ValidationException( String.format( "Application name must be set and not be the default [%s]", DEFAULT_APPLICATION_NAME), "applicationName"); } // Make sure they specify a valid endpoint. try { new URL(this.endpoint); } catch (MalformedURLException e) { throw new ValidationException( String.format("Endpoint [%s] not recognized as a valid URL.", this.endpoint), "endpoint", e); } } }
/** Validates the properties for the Ad Manager session. */ private void validate() throws ValidationException { // Check for at least one authentication mechanism. if (this.oAuth2Credential == null) { throw new ValidationException("OAuth2 authentication must be used.", ""); } // Check that application name is not empty or the default. if (Strings.nullToEmpty(applicationName).trim().isEmpty() || applicationName.contains(DEFAULT_APPLICATION_NAME)) { throw new ValidationException( String.format( "Application name must be set and not be the default [%s]", DEFAULT_APPLICATION_NAME), "applicationName"); } // Make sure they specify a valid endpoint. try { new URL(this.endpoint); } catch (MalformedURLException e) { throw new ValidationException( String.format("Endpoint [%s] not recognized as a valid URL.", this.endpoint), "endpoint", e); } } }
/** * Validates the properties for the AdWords session. */ private void validate() throws ValidationException { // Check for at least one authentication mechanism. if (this.oAuth2Credential == null) { throw new ValidationException("OAuth2 authentication must be used.", ""); } // Check that the developer token is set. if (this.developerToken == null) { throw new ValidationException("A developer token must be set.", "developerToken"); } // Check that user agent is not empty or the default. if (Strings.isNullOrEmpty(userAgent) || userAgent.contains(DEFAULT_USER_AGENT)) { this.userAgent = UNKNOWN_USER_AGENT; } else if (!CharMatcher.ascii().matchesAllOf(userAgent)) { throw new ValidationException( String.format("User agent [%s] contains non-ASCII characters.", userAgent), "userAgent"); } // Make sure they specify an endpoint. try { new URL(this.endpoint); } catch (MalformedURLException e) { throw new ValidationException(String.format("Endpoint [%s] not recognized as a valid URL.", this.endpoint), "endpoint", e); } } }
/** * Validates the properties for the AdWords session. */ private void validate() throws ValidationException { // Check for at least one authentication mechanism. if (this.oAuth2Credential == null) { throw new ValidationException("OAuth2 authentication must be used.", ""); } // Check that the developer token is set. if (this.developerToken == null) { throw new ValidationException("A developer token must be set.", "developerToken"); } // Check that user agent is not empty or the default. if (Strings.isNullOrEmpty(userAgent) || userAgent.contains(DEFAULT_USER_AGENT)) { this.userAgent = UNKNOWN_USER_AGENT; } else if (!CharMatcher.ascii().matchesAllOf(userAgent)) { throw new ValidationException( String.format("User agent [%s] contains non-ASCII characters.", userAgent), "userAgent"); } // Make sure they specify an endpoint. try { new URL(this.endpoint); } catch (MalformedURLException e) { throw new ValidationException(String.format("Endpoint [%s] not recognized as a valid URL.", this.endpoint), "endpoint", e); } } }
/** * Validates the {@code GoogleClientSecrets} object. * @throws ValidationException if the {@code GoogleClientSecrets} did not * validate */ private void validate() throws ValidationException { if (Strings.isNullOrEmpty(clientId) || clientId.startsWith("INSERT_CLIENT_ID_HERE")) { throw new ValidationException(String.format( "Client ID must be set%s\nIf you do not have a client ID or secret, " + "please create one in the API console: https://console.developers.google.com", filePath != null ? generateFilePathWarning("clientId") : "."), "clientId"); } if (Strings.isNullOrEmpty(clientSecret) || clientId.startsWith("INSERT_CLIENT_SECRET_HERE")) { throw new ValidationException(String.format( "Client secret must be set%s\nIf you do not have a client ID or secret, " + "please create one in the API console: https://console.developers.google.com", filePath != null ? generateFilePathWarning("clientSecret") : "."), "clientSecret"); } }
/** * Validates the {@code GoogleClientSecrets} object. * @throws ValidationException if the {@code GoogleClientSecrets} did not * validate */ private void validate() throws ValidationException { if (Strings.isNullOrEmpty(clientId) || clientId.startsWith("INSERT_CLIENT_ID_HERE")) { throw new ValidationException(String.format( "Client ID must be set%s\nIf you do not have a client ID or secret, " + "please create one in the API console: https://console.developers.google.com", filePath != null ? generateFilePathWarning("clientId") : "."), "clientId"); } if (Strings.isNullOrEmpty(clientSecret) || clientId.startsWith("INSERT_CLIENT_SECRET_HERE")) { throw new ValidationException(String.format( "Client secret must be set%s\nIf you do not have a client ID or secret, " + "please create one in the API console: https://console.developers.google.com", filePath != null ? generateFilePathWarning("clientSecret") : "."), "clientSecret"); } }
|| !Strings.isNullOrEmpty(refreshToken); if (otherOAuthPropsSet) { throw new ValidationException("Multiple OAuth formats set. Please specify either " + "a service account key file or a client ID and secret, not both.", this.configFilePath != null ? generateFilePathWarning("jsonKeyFilePath") : "."); throw new ValidationException( "Service account user set, but no service account key file was specified.", "serviceAccountUser"); throw new ValidationException(String.format("Client ID must be set%s%n" + "If you do not have a client ID or secret, please create one in the API console: " + "https://console.developers.google.com/project", throw new ValidationException(String.format("Client secret must be set%s%n" + "If you do not have a client ID or secret, please create one in the API console: " + "https://console.developers.google.com/project", throw new ValidationException(String.format("A refresh token must be set%s%n" + "It is required for offline credentials. If you need to create one, see the " + "GetRefreshToken example.",
|| !Strings.isNullOrEmpty(refreshToken); if (otherOAuthPropsSet) { throw new ValidationException("Multiple OAuth formats set. Please specify either " + "a service account key file or a client ID and secret, not both.", this.configFilePath != null ? generateFilePathWarning("jsonKeyFilePath") : "."); throw new ValidationException( "Service account user set, but no service account key file was specified.", "serviceAccountUser"); throw new ValidationException(String.format("Client ID must be set%s%n" + "If you do not have a client ID or secret, please create one in the API console: " + "https://console.developers.google.com/project", throw new ValidationException(String.format("Client secret must be set%s%n" + "If you do not have a client ID or secret, please create one in the API console: " + "https://console.developers.google.com/project", throw new ValidationException(String.format("A refresh token must be set%s%n" + "It is required for offline credentials. If you need to create one, see the " + "GetRefreshToken example.",