-
Notifications
You must be signed in to change notification settings - Fork 399
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 being thrown when trying to authenticate with google sheets api #93
Comments
Check your client secrets file to make sure it's correct. Possible that you downloaded credentials in the wrong form. That error indicates it's not in the expected format as isn't either for a server-side web app or installed (desktop) app. Corresponding code: https://github.com/googleapis/google-api-java-client/blob/master/google-api-client/src/main/java/com/google/api/client/googleapis/auth/oauth2/GoogleClientSecrets.java |
Ping @aeslami3574 -- please verify your credentials are the correct type. Otherwise will close issue as not reproducible. |
I had the same issue using the wrong My credentials file should looks like this:
|
My workaround: Don't use the client secrets, instead, directly build the credentials. Import this library <dependency>
<groupId>com.google.auth</groupId>
<artifactId>google-auth-library-oauth2-http</artifactId>
<version>1.3.0</version>
</dependency> InputStream in = SheetsQuickstart.class.getResourceAsStream(CREDENTIALS_FILE_PATH);
if (in == null) {
throw new FileNotFoundException("Resource not found: " + CREDENTIALS_FILE_PATH);
}
GoogleCredentials googleCredentials = GoogleCredentials.fromStream(in).createScoped(SCOPES);
Sheets service = new Sheets.Builder(HTTP_TRANSPORT, JSON_FACTORY, new HttpCredentialsAdapter(googleCredentials))
.setApplicationName(APPLICATION_NAME)
.build(); |
This is the most accurate answer until today. |
Works like a charm! THANK YOU @Johnny850807 |
(Please fill out these details before submitting an issue)
Sample Name
Modified version of https://developers.google.com/sheets/api/quickstart/java
Expected Behavior
Was expecting to receive a
Credential
object after successfully authenticating with the google apiActual
Specifications
The text was updated successfully, but these errors were encountered: