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

IllegalArgumentException from OAuthApp when passing in tokens #41

Open
eschultink opened this issue Nov 10, 2016 · 4 comments
Open

IllegalArgumentException from OAuthApp when passing in tokens #41

eschultink opened this issue Nov 10, 2016 · 4 comments

Comments

@eschultink
Copy link
Contributor

eschultink commented Nov 10, 2016

Trying to migrate to v0.5, we're using the new OAuthApp constructor that accepts a refresh token, as follows:

 OAuthApp oauthApp = new OAuthApp(
 clientId,
 clientSecret,
 redirectUri,
 accessToken,
 refreshToken,
 httpTransport,
 jsonFactory
 );

But we get an exception like the following:

java.lang.IllegalArgumentException: Please use the Builder and call setJsonFactory, setTransport, setClientAuthentication and setTokenServerUrl/setTokenServerEncodedUrl
at com.google.api.client.repackaged.com.google.common.base.Preconditions.checkArgument (Preconditions.java:125)
at com.google.api.client.util.Preconditions.checkArgument (Preconditions.java:49)
at com.google.api.client.auth.oauth2.Credential.setRefreshToken (Credential.java:380)
at com.asana.OAuthApp.<init> (OAuthApp.java:60)

And related, as it's not using Credential.Builder, it doesn't respect use of the JsonFactory/HttpTransport dependencies that are passed into the constructor.

This is actually one-and-the-same bug; If you look at the check failing in Credential, it's that you must first have specified transport/jsonfactory/etc so that it knows how to use the refresh token.

@praecipula
Copy link
Contributor

Hey, @eschultink, thanks for letting us know! It does look like constructing the app with a refresh token passed in isn't doing the right thing - that is, in Google's examples, the code path for not having a refresh token is clearly different from when you do specify a token, so we should be following that lead.

@andorep
Copy link

andorep commented Mar 22, 2018

¿Theres an alternative to solve this bug?

@matfury
Copy link

matfury commented Aug 3, 2018

Anything? I just came across this issue and I have no way to use my refreshToken without a valid way to construct a credential?

@christophpre
Copy link
Contributor

christophpre commented Apr 18, 2019

Any news on this? As of version 0.8.1 this problem is still not solved. Creating an OAuthApp with a refreshToken is currently not possible.

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

Successfully merging a pull request may close this issue.

5 participants