Код: Выделить всё
com.google.api.client.auth.oauth2.TokenResponseException: 401 Unauthorized
POST https://oauth2.googleapis.com/token
at com.google.api.client.auth.oauth2.TokenResponseException.from(TokenResponseException.java:103)
at com.google.api.client.auth.oauth2.TokenRequest.executeUnparsed(TokenRequest.java:308)
at com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeTokenRequest.execute(GoogleAuthorizationCodeTokenRequest.java:166)
at com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeTokenRequest.execute(GoogleAuthorizationCodeTokenRequest.java:72)
at com.google.api.client.extensions.servlet.auth.oauth2.jakarta.AbstractAuthorizationCodeCallbackServlet.doGet(AbstractAuthorizationCodeCallbackServlet.java:122)...
< /code>
Мои коды для проверки и токена обновления: < /p>
String keys = googleCal.getCredential();//get credential from datastore based on a user key
InputStream stream = new ByteArrayInputStream(keys.getBytes(Charset.forName("UTF-8")));
GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(JSON_FACTORY, new InputStreamReader(stream));
DataStoreFactory dataStore = new JPADataStoreFactory(repository);
NetHttpTransport HTTP_TRANSPORT = GoogleNetHttpTransport.newTrustedTransport();
GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(
HTTP_TRANSPORT, JSON_FACTORY, clientSecrets, SCOPES)
.setDataStoreFactory(dataStore)
.setApprovalPrompt("force")
.setAccessType("offline")
.build();
Любое предложение будет оценено.
Подробнее здесь: https://stackoverflow.com/questions/796 ... authorized