Search in sources :

Example 1 with GitHubToken

use of com.meisolsson.githubsdk.model.GitHubToken in project PocketHub by pockethub.

the class LoginActivity method onUserLoggedIn.

private void onUserLoggedIn(Uri uri) {
    if (uri != null && uri.getScheme().equals(getString(R.string.github_oauth_scheme))) {
        openLoadingDialog();
        String code = uri.getQueryParameter("code");
        RequestToken request = RequestToken.builder().clientId(clientId).clientSecret(secret).redirectUri(redirectUri).code(code).build();
        ServiceGenerator.createAuthService().getToken(request).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).as(AutoDisposeUtils.bindToLifecycle(this)).subscribe(response -> {
            GitHubToken token = response.body();
            if (token.accessToken() != null) {
                endAuth(token.accessToken(), token.scope());
            } else if (token.error() != null) {
                Toast.makeText(this, token.error(), Toast.LENGTH_LONG).show();
                progressDialog.dismiss();
            }
        }, Throwable::printStackTrace);
    }
}
Also used : RequestToken(com.meisolsson.githubsdk.model.request.RequestToken) GitHubToken(com.meisolsson.githubsdk.model.GitHubToken)

Aggregations

GitHubToken (com.meisolsson.githubsdk.model.GitHubToken)1 RequestToken (com.meisolsson.githubsdk.model.request.RequestToken)1