mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
[googletts] Fix authorization from returning null refresh token (#13042)
Signed-off-by: Mark Hilbush <mark@hilbush.com>
This commit is contained in:
parent
8a8add71df
commit
00400562d4
@ -39,7 +39,7 @@ Using your favorite configuration UI to edit **Settings / Other Services - Googl
|
||||
* **Client Secret** - Google Cloud Platform OAuth 2.0-Client Secret.
|
||||
* **Authorization Code** - This code is used once for retrieving the Google Cloud Platform access and refresh tokens.
|
||||
**Please go to your browser ...**
|
||||
[https://accounts.google.com/o/oauth2/v2/auth?scope=https://www.googleapis.com/auth/cloud-platform&access_type=offline&include_granted_scopes=true&response_type=code&redirect_uri=https://www.google.com&client_id=<clientId>](https://accounts.google.com/o/oauth2/v2/auth?scope=https://www.googleapis.com/auth/cloud-platform&access_type=offline&include_granted_scopes=true&response_type=code&redirect_uri=https://www.google.com&client_id=<clientId>) (replace `<clientId>` by your Client Id)
|
||||
[https://accounts.google.com/o/oauth2/v2/auth?scope=https://www.googleapis.com/auth/cloud-platform&access_type=offline&include_granted_scopes=true&response_type=code&redirect_uri=https://www.google.com&client_id=<clientId>](https://accounts.google.com/o/oauth2/v2/auth?scope=https://www.googleapis.com/auth/cloud-platform&access_type=offline&prompt=consent&include_granted_scopes=true&response_type=code&redirect_uri=https://www.google.com&client_id=<clientId>) (replace `<clientId>` by your Client Id)
|
||||
**... to generate an authorization code and paste it here**.
|
||||
After your browser has been redirected to https://www.google.com, the authorization code will be set in the browser URL as value of the "code" URL query parameter.
|
||||
After initial authorization, this code is not needed anymore.
|
||||
|
@ -189,7 +189,11 @@ class GoogleCloudAPI {
|
||||
if (authcode != null && !authcode.isEmpty()) {
|
||||
logger.debug("Trying to get access and refresh tokens.");
|
||||
try {
|
||||
oAuthService.getAccessTokenResponseByAuthorizationCode(authcode, GCP_REDIRECT_URI);
|
||||
AccessTokenResponse response = oAuthService.getAccessTokenResponseByAuthorizationCode(authcode,
|
||||
GCP_REDIRECT_URI);
|
||||
if (response.getRefreshToken() == null || response.getRefreshToken().isEmpty()) {
|
||||
throw new AuthenticationException("Error fetching refresh token. Please reauthorize");
|
||||
}
|
||||
} catch (OAuthException | OAuthResponseException e) {
|
||||
logger.debug("Error fetching access token: {}", e.getMessage(), e);
|
||||
throw new AuthenticationException(
|
||||
@ -232,6 +236,9 @@ class GoogleCloudAPI {
|
||||
|| accessTokenResponse.getAccessToken().isEmpty()) {
|
||||
throw new AuthenticationException("No access token. Is this thing authorized?");
|
||||
}
|
||||
if (accessTokenResponse.getRefreshToken() == null || accessTokenResponse.getRefreshToken().isEmpty()) {
|
||||
throw new AuthenticationException("No refresh token. Please reauthorize");
|
||||
}
|
||||
return BEARER + accessTokenResponse.getAccessToken();
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
||||
</parameter>
|
||||
<parameter name="authcode" type="text" groupName="authentication">
|
||||
<label>Authorization Code</label>
|
||||
<description><![CDATA[This code is used once for retrieving the Google Cloud Platform access and refresh tokens. Open the following URL in your browser to generate an authorization code:<br><br>https://accounts.google.com/o/oauth2/v2/auth?scope=https://www.googleapis.com/auth/cloud-platform&access_type=offline&include_granted_scopes=true&response_type=code&redirect_uri=https://www.google.com&client_id={{clientId}}<br><br>After your browser has been redirected to https://www.google.com, the authorization code will be set in the browser URL as value of the "code" URL query parameter.]]></description>
|
||||
<description><![CDATA[This code is used once for retrieving the Google Cloud Platform access and refresh tokens. Open the following URL in your browser to generate an authorization code:<br><br>https://accounts.google.com/o/oauth2/v2/auth?scope=https://www.googleapis.com/auth/cloud-platform&access_type=offline&prompt=consent&include_granted_scopes=true&response_type=code&redirect_uri=https://www.google.com&client_id={{clientId}}<br><br>After your browser has been redirected to https://www.google.com, the authorization code will be set in the browser URL as value of the "code" URL query parameter.]]></description>
|
||||
</parameter>
|
||||
<parameter name="pitch" type="decimal" min="-20" max="20" step="0.1" groupName="tts">
|
||||
<label>Pitch</label>
|
||||
|
@ -1,5 +1,5 @@
|
||||
voice.config.googletts.authcode.label = Authorization Code
|
||||
voice.config.googletts.authcode.description = This code is used once for retrieving the Google Cloud Platform access and refresh tokens. Open the following URL in your browser to generate an authorization code:<br><br>https://accounts.google.com/o/oauth2/v2/auth?scope=https://www.googleapis.com/auth/cloud-platform&access_type=offline&include_granted_scopes=true&response_type=code&redirect_uri=https://www.google.com&client_id={{clientId}}<br><br>After your browser has been redirected to https://www.google.com, the authorization code will be set in the browser URL as value of the "code" URL query parameter.
|
||||
voice.config.googletts.authcode.description = This code is used once for retrieving the Google Cloud Platform access and refresh tokens. Open the following URL in your browser to generate an authorization code:<br><br>https://accounts.google.com/o/oauth2/v2/auth?scope=https://www.googleapis.com/auth/cloud-platform&access_type=offline&prompt=consent&include_granted_scopes=true&response_type=code&redirect_uri=https://www.google.com&client_id={{clientId}}<br><br>After your browser has been redirected to https://www.google.com, the authorization code will be set in the browser URL as value of the "code" URL query parameter.
|
||||
voice.config.googletts.clientId.label = Client Id
|
||||
voice.config.googletts.clientId.description = Google Cloud Platform OAuth 2.0-Client Id.
|
||||
voice.config.googletts.clientSecret.label = Client Secret
|
||||
|
Loading…
Reference in New Issue
Block a user