use of com.meisolsson.githubsdk.service.OAuthService in project gh4a by slapperwan.
the class Github4AndroidActivity method handleIntent.
private boolean handleIntent(Intent intent) {
Uri data = intent.getData();
if (data != null && data.getScheme().equals(CALLBACK_URI.getScheme()) && data.getHost().equals(CALLBACK_URI.getHost())) {
OAuthService service = ServiceGenerator.createAuthService();
RequestToken request = RequestToken.builder().clientId(BuildConfig.CLIENT_ID).clientSecret(BuildConfig.CLIENT_SECRET).code(data.getQueryParameter(PARAM_CODE)).build();
service.getToken(request).map(ApiHelpers::throwOnFailure).flatMap(token -> {
UserService userService = ServiceFactory.get(UserService.class, true, null, token.accessToken(), null);
Single<User> userSingle = userService.getUser().map(ApiHelpers::throwOnFailure);
return Single.zip(Single.just(token), userSingle, (t, user) -> Pair.create(t.accessToken(), user));
}).compose(RxUtils::doInBackground).subscribe(pair -> onLoginFinished(pair.first, pair.second), this::handleLoadFailure);
return true;
}
return false;
}
Aggregations