Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GoogleAPIClientSingle example #22

Closed
josh-burton opened this issue Mar 10, 2017 · 3 comments
Closed

GoogleAPIClientSingle example #22

josh-burton opened this issue Mar 10, 2017 · 3 comments

Comments

@josh-burton
Copy link

Can you provide an example of how to use GoogleAPIClientSingle?

It seems if I subscribe to this single, and flatMap to another observable where I can use the client, the client is disconnected before the chain completes.

@patloew
Copy link
Owner

patloew commented Mar 10, 2017

Could you please provide the whole chain where the problem occurs? I'll look into it then.

@josh-burton
Copy link
Author

josh-burton commented Mar 16, 2017

I'm attempting to use it like this:

    GoogleAPIClientSingle.create(context, Auth.CREDENTIALS_API)
        .flatMap(client -> Single.create(new SingleOnSubscribe<CredentialRequestResult>() {
            @Override
            public void subscribe(SingleEmitter<CredentialRequestResult> emitter) throws Exception {
                 CredentialRequest credentialRequest = new CredentialRequest.Builder()
                         .setPasswordLoginSupported(true)
                         .build();

                 Auth.CredentialsApi.request(client, credentialRequest).setResultCallback(new ResultCallback<CredentialRequestResult>() {
                     @Override
                     public void onResult(@NonNull CredentialRequestResult result) {
                         emitter.onSuccess(result);
                     }
                 });

             }
     }));

@patloew
Copy link
Owner

patloew commented Mar 24, 2017

The problem was that Single immediately unsubscribes when onSuccess() is called. I refactored it to GoogleApiClientFlowable, which should work now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants