Monday, July 23, 2012

Re: Authentication error when opening connection to cloud SQL in the development server

Hi Jordi,

I am facing the same issue with Google Cloud SQL command line tool :

Exiting; Unable to open connection.
unauthorized_client: 


Have you been able to resolve this error ???


Thanks in advance.

Regards,
Partho.

On Monday, April 9, 2012 4:06:02 AM UTC+5:30, Jordi Poch wrote:
Hi,

I am testing Google app Engine with Cloud SQL. I use:
- App engine SDK 1.6.2.1
- maven-gae-plugin v0.9.2

Some days ago I managed to get my application correctly running in the development server and connecting to my cloud SQL instance. However, now I face (I don't know why) the following problem. When start running the application, I see the following warnings in the console:

ADVERTENCIA: Authentication error: Unable to respond to any of these challenges: {authsub=WWW-Authenticate: AuthSub realm="https://www.google.com/accounts/AuthSubRequest" allowed-scopes="https://www.googleapis.com/auth/sqlservice"}
08-abr-2012 22:13:14 com.google.appengine.repackaged.org.apache.http.impl.client.DefaultRequestDirector handleResponse
ADVERTENCIA: Authentication error: Unable to respond to any of these challenges: {authsub=WWW-Authenticate: AuthSub realm="https://www.google.com/accounts/AuthSubRequest" allowed-scopes="https://www.googleapis.com/auth/sqlservice"}
08-abr-2012 22:13:14 com.google.appengine.api.rdbms.dev.LocalRdbmsServiceLocalDriver openConnection


Followed by this error:

GRAVE: Could not allocate a connection
java.sql.SQLException: unauthorized_client:
    at com.google.cloud.sql.jdbc.internal.googleapi.RpcGoogleApi.newOpenConnectionIOException(RpcGoogleApi.java:187)
    at com.google.cloud.sql.jdbc.internal.googleapi.RpcGoogleApi.openConnection(RpcGoogleApi.java:105)
    at com.google.cloud.sql.jdbc.internal.SqlProtoClient.openConnection(SqlProtoClient.java:58)
    at com.google.cloud.sql.jdbc.Driver.connect(Driver.java:59)
    at com.google.cloud.sql.Driver.connectImpl(Driver.java:105)
    at com.google.cloud.sql.Driver.connect(Driver.java:94)
    at com.google.cloud.sql.Driver.connect(Driver.java:31)
    at java.sql.DriverManager.getConnection(DriverManager.java:582)
    at java.sql.DriverManager.getConnection(DriverManager.java:154)
    at com.google.appengine.api.rdbms.dev.LocalRdbmsServiceLocalDriver.openConnection(LocalRdbmsServiceLocalDriver.java:142)
    at com.google.appengine.api.rdbms.dev.LocalRdbmsService.openConnection(LocalRdbmsService.java:121)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.google.appengine.tools.development.ApiProxyLocalImpl$AsyncApiCall.callInternal(ApiProxyLocalImpl.java:498)
    at com.google.appengine.tools.development.ApiProxyLocalImpl$AsyncApiCall.call(ApiProxyLocalImpl.java:452)
    at com.google.appengine.tools.development.ApiProxyLocalImpl$AsyncApiCall.call(ApiProxyLocalImpl.java:430)
    at java.util.concurrent.Executors$PrivilegedCallable$1.run(Executors.java:463)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.util.concurrent.Executors$PrivilegedCallable.call(Executors.java:460)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
Caused by: com.google.cloud.sql.jdbc.internal.googleapi.RefreshTokenAccessTokenRefresher$OAuth2AuthorizationException: unauthorized_client:
    at com.google.cloud.sql.jdbc.internal.googleapi.RefreshTokenAccessTokenRefresher.refreshAccessToken(RefreshTokenAccessTokenRefresher.java:55)
    at com.google.cloud.sql.jdbc.internal.googleapi.RpcGoogleApi$DefaultGoogleApi.refreshAccessToken(RpcGoogleApi.java:330)
    at com.google.cloud.sql.jdbc.internal.googleapi.RpcGoogleApi$DefaultGoogleApi.exec(RpcGoogleApi.java:321)
    at com.google.cloud.sql.jdbc.internal.googleapi.RpcGoogleApi.openConnection(RpcGoogleApi.java:100)
    ... 24 more
Caused by: com.google.api.client.http.HttpResponseException: 400 OK
    at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:789)
    at com.google.api.client.auth.oauth2.draft10.AccessTokenRequest.executeUnparsed(AccessTokenRequest.java:459)
    at com.google.cloud.sql.jdbc.internal.googleapi.RefreshTokenAccessTokenRefresher.refreshAccessToken(RefreshTokenAccessTokenRefresher.java:48)
    ... 27 more


However, if I execute the application in the development server using de Google plugin for Eclipse, it works Ok. And it also runs fine in the appengine server (deploying with both Google plugin for Eclipse and maven-gae-plugin).

Curiously, I was also trying the Cloud SQL Command Line Tool and also found the same problem when executed the command "google_sql.cmd <instance>":

Exiting; Unable to open connection.
unauthorized_client:


Any idea?

Thanks in advance.

No comments:

Post a Comment