Error reading credentials from stream, 'type' field not specified.
See original GitHub issueEnvironment details
- Create Web application credentials (web server app)
- OS type and version: macOS 10.15.6
- Java version: java8
- google-auth-library version(s): 1.3.0
Steps to reproduce
this is my json file :
{
"web": {
"client_id": "xxxxx-xxxxx.apps.googleusercontent.com",
"project_id": "xxxxx-xxxxx-xxxx",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_secret": "xxxxxx-xxxxx",
"redirect_uris": ["http://localhost:8888/Callback"]
}
}
Code example
GoogleCredentials credentials = GoogleCredentials.fromStream(new FileInputStream("/path/to/credentials.json"));
credentials.refreshIfExpired();
AccessToken token = credentials.getAccessToken();
// OR
AccessToken token = credentials.refreshAccessToken();
Stack trace
java.io.IOException: Error reading credentials from stream, 'type' field not specified.
at com.google.auth.oauth2.GoogleCredentials.fromStream(GoogleCredentials.java:166)
at com.google.auth.oauth2.GoogleCredentials.fromStream(GoogleCredentials.java:139)
how to solve this problem?
Thanks!
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
java.io.IOException: Error reading credentials from stream ...
The problem is that the file generated by the google-console for OAuth2 authentication doesn't contain a type field, that only the file ...
Read more >Error reading credentials from stream · Issue #141 - GitHub
Hi! I'm having this error: java.io.IOException: Error reading credentials from stream, 'type' field not specified.
Read more >com.google.auth.oauth2.UserCredentials.fromJson java code ...
Returns credentials defined by a JSON file stream using the format ... new IOException("Error reading credentials from stream, 'type' field not specified.
Read more >com.google.api.client.googleapis.auth.oauth2 ... - Java2s.com
Here is the source code for com.google.api.client.googleapis.auth.oauth2. ... throw new IOException("Error reading credentials from stream, 'type' field not ...
Read more >[NIFI] - GCPCredentialsControllerService - ListGCS... - 195519
[NIFI] - GCPCredentialsControllerService - ListGCSBucket ... lOException: Error reading credentials from stream, 'type' field not specified ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yes I read this code before I opened issues
but the json file obtained through this tutorial Create Web application credentials (web server app) does not have a
type
attribute.It’s exactly the same as below. I didn’t modify any information except sensitive information.
so I don’t know how to do it
Thanks @Sita04
closing since a solution was provided