expected format for config prior to oauth
outkaj opened this issue · comments
Hello,
Thanks for the nice library!
I have a quick question about val config = ConfigFactory.parseFile(new File("gdrive-test.conf")).getConfig("gdrive")
. What's the expected format of the config file here (as well as test-sessions
)?
I have tried parsing a Play config file (application.conf
) with an oidc.discoveryUri
, oidc.clientId
, and
oidc.clientSecret
(all set to environment variables) with val config = ConfigFactory.load()
. I also tried just directly passing JSON as val config = ConfigFactory.parseFile(new File("..."))
.
The JSON is the credentials.json
file downloaded from the Google API console, with content looking like:
{"web":{"client_id":"...","project_id":"...","auth_uri":"...","token_uri":"...","auth_provider_x509_cert_url":"...","client_secret":"...","redirect_uris":...,"javascript_origins":...}}
However, both fail with
[error] ErrorHandler - Unhandled error
java.lang.IllegalArgumentException: no JSON input found
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.json.JsonParser.startParsing(JsonParser.java:223)
at com.google.api.client.json.JsonParser.parse(JsonParser.java:380)
at com.google.api.client.json.JsonParser.parse(JsonParser.java:336)
at com.google.api.client.json.JsonParser.parseAndClose(JsonParser.java:166)
at com.google.api.client.json.JsonParser.parseAndClose(JsonParser.java:148)
at com.google.api.client.json.JsonFactory.fromReader(JsonFactory.java:236)
at com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets.load(GoogleClientSecrets.java:192)
at com.karasiq.gdrive.oauth.GDriveOAuth$.com$karasiq$gdrive$oauth$GDriveOAuth$$readSecrets(GDriveOAuth.scala:22)
Would it be possible for you to provide a mock example of the expected format?
Thanks very much for your time!
You should put the JSON under a oauth.secrets
section.
Here is my gdrive-test.conf
gdrive {
oauth.secrets = {"installed": {"client_id": "*******", "project_id": "*******", "auth_uri": "https://accounts.google.com/o/oauth2/auth", "token_uri": "https://accounts.google.com/o/oauth2/token", "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", "client_secret": "*****************", "redirect_uris": ["urn:ietf:wg:oauth:2.0:oob", "http://localhost"]}}
user = "example@gmail.com"
transport {
proxy {
host = localhost
port = 9999
}
http-parameters {
"http.conn-manager.max-per-route" = 64
}
}
}
Thank you, @Karasiq! That got rid of the no JSON input found
error. However, while the request correctly passes in my client secret, it is using http://localhost:*randomly generated five numbers (different each time)*/Callback"
for the redirect URI rather than the custom redirect URI I provided in the .conf
. Is there another place I need to pass in the custom redirect URI? Thanks again.
Library authorize
method uses "installed app" auth mechanism (localhost), if you want to use a web server with Play/Akka/etc, you should hack around the authFlow
object.
Google documentation provides examples only for the Java Servlets and the Google App Engine: https://developers.google.com/api-client-library/java/google-api-java-client/oauth2#web_server_applications
thank you! the use case is indeed web server with Play so I'll take a look at the authFlow
object. I'll close this.