Package x.oauth.client
Class OAuthClient
java.lang.Object
x.oauth.client.OAuthClient
OAuth 2.0 Main Services.
- Author:
- sakdsitt
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringdeleteScope(String scopeName) Delete a scope DELETE /oauth20/scopes/[scope]static StringGet all client application request : GET /oauth20/applications response :static StringGet all registered scopesstatic StringgetAppByClientId(String clientId) Get info about a client application by clientId request : GET /oauth20/applications/[client_id] response : {"name":[client_app_name],"description":[description],"scope":[scope],"registered":[registration_date]},"redirect_uri":[redirect_uri]static StringgetAuthCode(String clientId, String redirectURI, String responseType, String scope) 1.static StringgetScopeByClientId(String clientId) Get registered scopes by ClientID request : GET /oauth20/scopes?static StringgetScopeByName(String scopeName) Get registered scopes by Scope namestatic StringgetTokenAuthCode(String code, String redirect_uri, String client_id, String client_secret) The second step to issue an access token is to use the authorization code returned in the response of the step 1.static StringgetTokenClient(String client_id, String client_secret, String scope) 2.static StringgetTokenRefresh(String client_id, String client_secret, String refresh_token, String scope) 4.static StringgetTokenResource(String client_id, String client_secret, String username, String password, String scope) 3.static th.co.skylogicsystem.skyframework.core.utils.webservice.WebServiceManagerinit()static voidstatic StringregisterApp(String name, String description, String scope, String redirect_uri) Register a client application POST /oauth20/applications Content-Type: application/json {"name":[client application name],"description":[description],"scope":[scope], "redirect_uri":[redirect uri], "details":[refresh tokens expiration time in second],"client_id":[client id],"client_secret":[client secret]} POST http://127.0.0.1:8080/oauth20/applications Content-Type: application/json { "name": "test_app", "description": "test client app", "scope": "test_scope", "redirect_uri": "http://127.0.0.1:8080"static StringregisterScope(String scope, String description, String cc_expires_in, String pass_expires_in) Register a new scopestatic StringUpdate a client application PUT /oauth20/applications/[client_id] PUT http://127.0.0.1:8080/oauth20/applications/b9db6d84dc98a895035e68f972e30503d3c724c8 Content-Type: application/json { "description": "updated description", "scope": "test_scope", "application_details": { "division": "IT", "organization": "MM" } } Activate/Deactivate a client application PUT /oauth20/applications/[client_ id] PUT http://127.0.0.1:8080/oauth20/applications/b9db6d84dc98a895035e68f972e30503d3c724c8 Content-Type: application/json {"status":1}static StringupdateScope(String scopeName, String jsonUpdateScope) Update scope PUT /oauth20/scopes/[scope] Content-Type: application/json {"description":[description],"cc_expires_in":[client credentials tokens expiration time in seconds], "pass_expires_in":[password tokens expiration time in seconds], "refresh_expires_in":[refresh tokens expiration time in second]} PUT http://127.0.0.1:8080/oauth20/scopes Content-Type: application/json {"description":"new basic scope description"}
-
Method Details
-
init
public static th.co.skylogicsystem.skyframework.core.utils.webservice.WebServiceManager init() -
registerScope
public static String registerScope(String scope, String description, String cc_expires_in, String pass_expires_in) throws IOException Register a new scope- Throws:
IOException
-
getAllScope
Get all registered scopes- Throws:
IOException
-
getScopeByName
Get registered scopes by Scope name- Throws:
IOException
-
getScopeByClientId
Get registered scopes by ClientID request : GET /oauth20/scopes?client_id=xxx response : [{"scope":[scope_name],"description":[description],"cc_expires_in":[cc_expires_in],"pass_expires_in":[pass_expires_in]},...]- Throws:
IOException
-
updateScope
Update scope PUT /oauth20/scopes/[scope] Content-Type: application/json {"description":[description],"cc_expires_in":[client credentials tokens expiration time in seconds], "pass_expires_in":[password tokens expiration time in seconds], "refresh_expires_in":[refresh tokens expiration time in second]} PUT http://127.0.0.1:8080/oauth20/scopes Content-Type: application/json {"description":"new basic scope description"}- Throws:
IOException
-
deleteScope
Delete a scope DELETE /oauth20/scopes/[scope]- Throws:
IOException
-
registerApp
public static String registerApp(String name, String description, String scope, String redirect_uri) throws IOException Register a client application POST /oauth20/applications Content-Type: application/json {"name":[client application name],"description":[description],"scope":[scope], "redirect_uri":[redirect uri], "details":[refresh tokens expiration time in second],"client_id":[client id],"client_secret":[client secret]} POST http://127.0.0.1:8080/oauth20/applications Content-Type: application/json { "name": "test_app", "description": "test client app", "scope": "test_scope", "redirect_uri": "http://127.0.0.1:8080"- Throws:
IOException
-
updateApp
Update a client application PUT /oauth20/applications/[client_id] PUT http://127.0.0.1:8080/oauth20/applications/b9db6d84dc98a895035e68f972e30503d3c724c8 Content-Type: application/json { "description": "updated description", "scope": "test_scope", "application_details": { "division": "IT", "organization": "MM" } } Activate/Deactivate a client application PUT /oauth20/applications/[client_ id] PUT http://127.0.0.1:8080/oauth20/applications/b9db6d84dc98a895035e68f972e30503d3c724c8 Content-Type: application/json {"status":1}- Throws:
IOException
-
getAllApps
Get all client application request : GET /oauth20/applications response :- Throws:
IOException
-
getAppByClientId
Get info about a client application by clientId request : GET /oauth20/applications/[client_id] response : {"name":[client_app_name],"description":[description],"scope":[scope],"registered":[registration_date]},"redirect_uri":[redirect_uri]- Throws:
IOException
-
getAuthCode
public static String getAuthCode(String clientId, String redirectURI, String responseType, String scope) throws IOException 1. Authorization code flow first step, obtaining an authorization code- Throws:
IOException
-
getTokenAuthCode
public static String getTokenAuthCode(String code, String redirect_uri, String client_id, String client_secret) throws IOException The second step to issue an access token is to use the authorization code returned in the response of the step 1.- Throws:
IOException
-
getTokenClient
public static String getTokenClient(String client_id, String client_secret, String scope) throws IOException 2. Client credentials grant type Obtain a client credentials access token- Throws:
IOException
-
getTokenResource
public static String getTokenResource(String client_id, String client_secret, String username, String password, String scope) throws IOException 3. Resource owner password credentials grant Access tokens with grant type client credentials are obtained by posting a request to /oauth20/tokens with grant_type=password. Here is an example request:- Throws:
IOException
-
getTokenRefresh
public static String getTokenRefresh(String client_id, String client_secret, String refresh_token, String scope) throws IOException 4. Refresh token grant type Access tokens with grant type client credentials are obtained by posting a request to /oauth20/tokens with grant_type=refresh_token. Here is an example request:- Throws:
IOException
-
main
-