public class AuthHandler extends Object
generateAuthorizationUrl(io.scanbot.shoeboxed.AuthHandler.Scope)
2. You will be redirected to ApiApplication.getRedirectUri() with appended query parameters
in URL. Path this URL to getTokens(String)
3. As a result you'll receive access and refresh tokens. You can persist them and use with ShoeboxedSession
Note, that AuthHandler class keeps track of last generated URL, therefore you should not generate new one
before calling getTokens(String), as it will result in AuthHandler.StateMismatchException
Thread safe.| Modifier and Type | Class and Description |
|---|---|
static class |
AuthHandler.Scope
Available OAuth scopes
|
static class |
AuthHandler.StateMismatchException
Thrown if state generated in
generateAuthorizationUrl(io.scanbot.shoeboxed.AuthHandler.Scope) does not
match state passed in getTokensFromAuthorizationCode(String, String) method. |
static class |
AuthHandler.Tokens
Container for access and refresh tokens
|
| Modifier and Type | Method and Description |
|---|---|
static AuthHandler |
forApplication(ApiApplication apiApplication) |
String |
generateAuthorizationUrl(AuthHandler.Scope scope)
Generates URL for authentication.
|
AuthHandler.Tokens |
getTokens(String url)
Requests token for given URL with authentication code.
|
AuthHandler.Tokens |
refreshTokens(String refreshToken)
Request new access token for given refresh token
|
public static AuthHandler forApplication(ApiApplication apiApplication)
AuthHandler for given ApiApplicationpublic String generateAuthorizationUrl(AuthHandler.Scope scope)
AuthHandler class keeps track of last generated URL, therefore you should not generate new one
before calling getTokens(String), as it will result in AuthHandler.StateMismatchExceptionscope - AuthHandler.Scope for which to build authorization URLpublic AuthHandler.Tokens getTokens(String url) throws MalformedURLException, IOException
url - URL to which user is redirected after authentication with generateAuthorizationUrl(io.scanbot.shoeboxed.AuthHandler.Scope)IOException - in case of communication errorMalformedURLException - if given URL is not valid or does not contain authentication parameterspublic AuthHandler.Tokens refreshTokens(String refreshToken) throws IOException
IOException - in case of communication errorCopyright © 2014. All rights reserved.