The Application Default Credentials are not available. They are available if running on Google App Engine, Google Compute Engine, or Google Cloud Shell. Otherwise, the environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined pointing to a

9.739 weergaven
Naar het eerste ongelezen bericht

Charlie Mich

ongelezen,
16 feb 2017, 14:32:4916-02-2017
aan Google Cloud SQL discuss
Feb 17, 2017 2:55:57 AM com.google.cloud.sql.mysql.SocketFactory connect
INFO: Connecting to Cloud SQL instance [xx1:xx2:xx3].
Feb 17, 2017 2:55:57 AM com.google.cloud.sql.mysql.SslSocketFactory getInstance
INFO: First Cloud SQL connection, generating RSA key pair.
===========================
CM25 == > The Application Default Credentials are not available. They are available if running on Google App Engine, Google Compute Engine, or Google Cloud Shell. Otherwise, the environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined pointing to a file defining the credentials. See https://developers.google.com/accounts/docs/application-default-credentials for more information.
===========================
Feb 17, 2017 2:56:07 AM com.google.cloud.sql.mysql.example.ListTables koneksi
SEVERE: null
java.sql.SQLNonTransientConnectionException: Could not create connection to database server.
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:676)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:663)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:653)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:638)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:606)
at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:1837)
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:1653)
at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:662)
at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:352)
at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:221)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at com.google.cloud.sql.mysql.example.ListTables.koneksi(ListTables.java:46)
at com.google.cloud.sql.mysql.example.ListTables.<init>(ListTables.java:23)
at com.google.cloud.sql.mysql.example.ListTables.main(ListTables.java:65)
Caused by: java.lang.RuntimeException: Unable to obtain credentials to communicate with the Cloud SQL API
at com.google.cloud.sql.mysql.SslSocketFactory$ApplicationDefaultCredentialFactory.create(SslSocketFactory.java:543)
at com.google.cloud.sql.mysql.SslSocketFactory.getInstance(SslSocketFactory.java:133)
at com.google.cloud.sql.mysql.SocketFactory.connect(SocketFactory.java:39)
at com.mysql.cj.mysqla.io.MysqlaSocketConnection.connect(MysqlaSocketConnection.java:57)
at com.mysql.cj.mysqla.MysqlaSession.connect(MysqlaSession.java:144)
at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:1783)
... 9 more
Caused by: java.io.IOException: The Application Default Credentials are not available. They are available if running on Google App Engine, Google Compute Engine, or Google Cloud Shell. Otherwise, the environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined pointing to a file defining the credentials. See https://developers.google.com/accounts/docs/application-default-credentials for more information.
at com.google.api.client.googleapis.auth.oauth2.DefaultCredentialProvider.getDefaultCredential(DefaultCredentialProvider.java:98)
at com.google.api.client.googleapis.auth.oauth2.GoogleCredential.getApplicationDefault(GoogleCredential.java:213)
at com.google.api.client.googleapis.auth.oauth2.GoogleCredential.getApplicationDefault(GoogleCredential.java:191)
at com.google.cloud.sql.mysql.SslSocketFactory$ApplicationDefaultCredentialFactory.create(SslSocketFactory.java:538)
... 14 more

Koneksi Gagal : Could not create connection to database server.

Alex (Cloud Platform Support)

ongelezen,
16 feb 2017, 17:29:3416-02-2017
aan Google Cloud SQL discuss

Hi Charlie,


This appears to be a request for 1-on-1 assistance with a technical issue specific to your development. This isn't the right forum to look for help on such a question, which is perfectly suited to stackoverflow.com. This forum, on the other hand, is meant for more general high-level discussion of the platform and services, design patterns, etc.


As for how to assist with the issue itself, you may want to have a look on How the Application Default Credentials work documentation. As indicated, in case the environment variable GOOGLE_APPLICATION_CREDENTIALS is checked and specified, it should point to a file that defines the default credentials. Moreover this documentation provides a guide on how to get this credentials file.


Alternatively, you may solve your error by installing and logging into the Cloud SDK as indicated in the second point of this same section.


In case you are still running into issues, can you reply with the exact command you are running when getting this error?

Allen beantwoorden
Auteur beantwoorden
Doorsturen
0 nieuwe berichten