-
-
Save skiph/dec5fbc0a6a622deb9f46400082969d4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void startServiceConfig() { | |
Log.i(TAG, "Starting service config"); | |
String discoveryEndpoint = app.getString(R.string.discovery_endpoint); | |
if (discoveryEndpoint.trim().length() == 0 || !URLUtil.isValidUrl(discoveryEndpoint)) { | |
Log.i(TAG, "Using static service config"); | |
AuthorizationServiceConfiguration serviceConfig = | |
new AuthorizationServiceConfiguration( | |
Uri.parse(app.getString(R.string.authorization_endpoint)), | |
Uri.parse(app.getString(R.string.token_endpoint))); | |
authState = new AuthState(serviceConfig); | |
userInfoUrl = app.getString(R.string.user_info_endpoint); | |
finishServiceConfig(); | |
} else { | |
Log.i(TAG, "Using discovery service config"); | |
Uri discoveryUri = Uri.parse(discoveryEndpoint); | |
loginListener.onEvent(AuthRepo.this, AUTH_SERVICE_DISCOVERY_START); | |
AuthorizationServiceConfiguration.fetchFromUrl(discoveryUri, this::finishServiceDiscovery); | |
} | |
} | |
private void finishServiceDiscovery(AuthorizationServiceConfiguration config, | |
AuthorizationException ex) { | |
if (config == null) { | |
failLogin(new AuthException("Failed to retrieve authorization service discovery document")); | |
return; | |
} | |
authState = new AuthState(config); | |
AuthorizationServiceDiscovery discovery = config.discoveryDoc; | |
userInfoUrl = discovery.getUserinfoEndpoint().toString(); | |
loginListener.onEvent(AuthRepo.this, AUTH_SERVICE_DISCOVERY_FINISH); | |
finishServiceConfig(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment