• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Frits Walraven
Bartenders:
  • Carey Brown
  • salvin francis
  • Claude Moore

IllegalArgumentException thrown from GoogleAuthorizationCodeFlow.Builder scopes argument  RSS feed

 
David Gillette
Greenhorn
Posts: 24
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm building a bot which uses a service account to connect to the Gmail API to read, write and send emails. This bot is going to be installed on one machine (workstation). I'm fairly confident I followed the configuration procedure correctly so the bot has all the necessary permissions to access the account. I should note this is the first time I have built anything that uses the Google API.

Every time I run the code, no matter what scopes are used (more or less permissive) or how I construct the scopes Collections object, the following exception is thrown and I am unable to determine the cause:



I'm attempting to get the authorization credentials, but an exception is thrown in the authorize() method at line 41. Please see the AuthenticationTest class below:



Line 41 calls a static method from the GmailCredsProps class:



Can anyone please offer insight, any guess, as to where the problem may be originating? Maybe, a better approach? Work around? Anything!
 
David Gillette
Greenhorn
Posts: 24
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've been able to narrow this down substantially. First, it wasn't the scopes argument. It was the GoogleClientSecrets argument that was throwing the exception. I should have seen it as it was line 4 in the error message. I got confused because I thought the line number in the error was pointing at the scopes argument, but it was pointing at the closing parenthesis in the GoogleAuthorizationCodeFlow.Builder parameter list.

I was able to edit the question on stackoverflow.com so that it is more concise and accurate. Here's the link if anyone would like to check it out:

https://stackoverflow.com/q/55544211/11319332

The problem is now: How to debug deeply to discover exactly what
com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets.getDetails(GoogleClientSecrets.java:82)
is looking for/at?
 
David Gillette
Greenhorn
Posts: 24
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I used the same InputStream twice. You can't do that. That was the problem. I was the problem.
 
David Gillette
Greenhorn
Posts: 24
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
and I updated the code to:


It works now.
 
Paul Clapham
Sheriff
Posts: 24374
55
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

David Gillette wrote:
I used the same InputStream twice. You can't do that. That was the problem. I was the problem.



Well, I'm impressed. It sure isn't obvious to me when I read the code. So congratulations on tracking that down. And thanks for coming back to post the solution!
 
David Gillette
Greenhorn
Posts: 24
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome.

The reason it isn't obvious is I didn't include all the code. The above is a trimmed down version and it went through about 10 different variations. I don't even know which variation I'm referring to anymore. Most importantly, I didn't get my beauty rest for the past two nights. Really, I'm just lost. It's a new API for me, fairly massive, and the online documentation isn't always straight forward. I thought this was going to be simple, but, oh boy, that turned out to be false. Plus, all the exceptions thrown led me down these strange dark smelly alleys that didn't have anything to do with the problem. Wouldn't it nice if IDE's included an AI that could throw a ConfusedCoderException? If there was a "Completely Lost" forum, that's where I would post everything.  
 
David Gillette
Greenhorn
Posts: 24
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And one other thing...

I think there may be a bug in GoogleClientSecrets.getDetails().getClientID() because it throws an exception while GoogleClientSecrets.get("client_id") does not. But I'm probably just doing something wrong again. Or maybe a missing library.

Slowly but surely as a snail crawling across ice in a blizzard, I'll get through this.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!