Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
Java Client API
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
2
Issues
2
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Genesys PGR
Java Client API
Commits
3ebc42f9
Commit
3ebc42f9
authored
Jan 14, 2016
by
Matija Obreza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Throw OAuthException when refresh token no longer valid
parent
4e9423a0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
4 deletions
+7
-4
src/main/java/org/genesys2/client/oauth/api/GenesysApi.java
src/main/java/org/genesys2/client/oauth/api/GenesysApi.java
+7
-4
No files found.
src/main/java/org/genesys2/client/oauth/api/GenesysApi.java
View file @
3ebc42f9
...
@@ -24,6 +24,7 @@ import org.apache.log4j.LogManager;
...
@@ -24,6 +24,7 @@ import org.apache.log4j.LogManager;
import
org.apache.log4j.Logger
;
import
org.apache.log4j.Logger
;
import
org.genesys2.client.oauth.GenesysApiException
;
import
org.genesys2.client.oauth.GenesysApiException
;
import
org.scribe.builder.api.DefaultApi20
;
import
org.scribe.builder.api.DefaultApi20
;
import
org.scribe.exceptions.OAuthException
;
import
org.scribe.extractors.AccessTokenExtractor
;
import
org.scribe.extractors.AccessTokenExtractor
;
import
org.scribe.extractors.JsonTokenExtractor
;
import
org.scribe.extractors.JsonTokenExtractor
;
import
org.scribe.model.OAuthConfig
;
import
org.scribe.model.OAuthConfig
;
...
@@ -37,20 +38,20 @@ import org.scribe.utils.OAuthEncoder;
...
@@ -37,20 +38,20 @@ import org.scribe.utils.OAuthEncoder;
* Genesys API v1.
* Genesys API v1.
*/
*/
public
class
GenesysApi
extends
DefaultApi20
{
public
class
GenesysApi
extends
DefaultApi20
{
/** The Constant _log. */
/** The Constant _log. */
private
static
final
Logger
_log
=
LogManager
.
getLogger
(
GenesysApi
.
class
);
private
static
final
Logger
_log
=
LogManager
.
getLogger
(
GenesysApi
.
class
);
/**
OAuth2 authorization endpoint that is appended to {@link #baseUrl}. */
/** OAuth2 authorization endpoint that is appended to {@link #baseUrl}. */
public
static
final
String
AUTHORIZE_URL
=
"/oauth/authorize?client_id=%s&client_secret=%s&response_type=code&redirect_uri=%s"
;
public
static
final
String
AUTHORIZE_URL
=
"/oauth/authorize?client_id=%s&client_secret=%s&response_type=code&redirect_uri=%s"
;
/**
OAuth2 access token endpoint that is appended to {@link #baseUrl}. */
/** OAuth2 access token endpoint that is appended to {@link #baseUrl}. */
private
static
final
String
TOKEN_ENDPOINT
=
"/oauth/token"
;
private
static
final
String
TOKEN_ENDPOINT
=
"/oauth/token"
;
/** The base URL of the Genesys server (e.g. https://www.genesys-pgr.org) */
/** The base URL of the Genesys server (e.g. https://www.genesys-pgr.org) */
private
String
baseUrl
;
private
String
baseUrl
;
/**
The complete authorization url. */
/** The complete authorization url. */
private
String
authorizeUrl
;
private
String
authorizeUrl
;
/** The scoped authorize url. */
/** The scoped authorize url. */
...
@@ -162,6 +163,8 @@ public class GenesysApi extends DefaultApi20 {
...
@@ -162,6 +163,8 @@ public class GenesysApi extends DefaultApi20 {
_log
.
debug
(
"Redirect: "
+
response
.
getHeader
(
HttpHeaders
.
LOCATION
));
_log
.
debug
(
"Redirect: "
+
response
.
getHeader
(
HttpHeaders
.
LOCATION
));
if
(
response
.
getCode
()
>=
200
&&
response
.
getCode
()
<
300
)
{
if
(
response
.
getCode
()
>=
200
&&
response
.
getCode
()
<
300
)
{
return
getAccessTokenExtractor
().
extract
(
response
.
getBody
());
return
getAccessTokenExtractor
().
extract
(
response
.
getBody
());
}
else
if
(
response
.
getCode
()
==
400
)
{
throw
new
OAuthException
(
"Refresh token no longer valid."
);
}
else
{
}
else
{
throw
new
GenesysApiException
(
"Server responded with unexpected HTTP response code "
+
response
.
getCode
());
throw
new
GenesysApiException
(
"Server responded with unexpected HTTP response code "
+
response
.
getCode
());
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment