public OAuth2Credentials build()

in uber-core-oauth-client-adapter/src/main/java/com/uber/sdk/core/auth/OAuth2Credentials.java [171:221]


        public OAuth2Credentials build() {
            validate();
            OAuth2Credentials oAuth2Credentials = new OAuth2Credentials();
            oAuth2Credentials.redirectUri = redirectUri;

            Set<String> allScopes = new TreeSet<>();

            if (scopes != null) {
                for (Scope scope : scopes) {
                    allScopes.add(scope.name().toLowerCase());
                }
            }

            if (customScopes != null) {
                allScopes.addAll(customScopes);
            }
            if (!allScopes.isEmpty()) {
                oAuth2Credentials.scopes = allScopes;
            }

            if (httpTransport == null) {
                httpTransport = new NetHttpTransport();
            }

            if (credentialDataStoreFactory == null) {
                credentialDataStoreFactory = MemoryDataStoreFactory.getDefaultInstance();
            }

            if (authorizationCodeFlow == null) {
                try {
                    AuthorizationCodeFlow.Builder builder =
                            new AuthorizationCodeFlow.Builder(
                                    BearerToken.authorizationHeaderAccessMethod(),
                                    httpTransport,
                                    new JacksonFactory(),
                                    new GenericUrl(loginHost + TOKEN_PATH),
                                    new ClientParametersAuthentication(clientId, clientSecret),
                                    clientId,
                                    loginHost + AUTHORIZATION_PATH);
                    if (oAuth2Credentials.scopes != null && !oAuth2Credentials.scopes.isEmpty()) {
                        builder.setScopes(oAuth2Credentials.scopes);
                    }
                    authorizationCodeFlow =
                            builder.setDataStoreFactory(credentialDataStoreFactory).build();
                } catch (IOException e) {
                    throw new IllegalStateException("Unexpected exception while building OAuth2Credentials.", e);
                }
            }
            oAuth2Credentials.authorizationCodeFlow = authorizationCodeFlow;
            return oAuth2Credentials;
        }