Class ClientCredentialsSession
java.lang.Object
com.janeirodigital.sai.authentication.ClientCredentialsSession
- All Implemented Interfaces:
AuthorizedSession,Serializable
Implementation of
AuthorizedSession for a Client Credentials authorization flow- See Also:
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionThe client credentials flows don't require refresh tokensprotected static AccessTokenobtainToken(String clientIdentifier, String clientSecret, URI oidcTokenEndpoint, com.nimbusds.oauth2.sdk.Scope scope) POSTs a token request to the token endpoint of the oidcProvider using the providedclientIdentifierandclientSecretto authenticate and request the providedscope.voidrefresh()"Refreshes" the session via another client credentials token request.toHttpHeaders(com.janeirodigital.sai.httputils.HttpMethod method, URI uri) Generates a map of HTTP Authorization headers that can be use to make authorized requests using the session.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.janeirodigital.sai.authentication.AuthorizedSession
getAccessToken, getApplicationId, getId, getOidcProviderId, getSocialAgentId
-
Method Details
-
toHttpHeaders
public Map<String,String> toHttpHeaders(com.janeirodigital.sai.httputils.HttpMethod method, URI uri) Generates a map of HTTP Authorization headers that can be use to make authorized requests using the session. Client credentials uses a Bearer token in a single authorization header.- Specified by:
toHttpHeadersin interfaceAuthorizedSession- Parameters:
method- not needed - can be null for client credentialsuri- not needed - can be null for client credentials- Returns:
- Map of HTTP Authorization headers
-
refresh
"Refreshes" the session via another client credentials token request. A client credentials flow doesn't require refresh tokens.- Specified by:
refreshin interfaceAuthorizedSession- Throws:
SaiAuthenticationException
-
getRefreshToken
The client credentials flows don't require refresh tokens- Specified by:
getRefreshTokenin interfaceAuthorizedSession- Returns:
- null
-
obtainToken
protected static AccessToken obtainToken(String clientIdentifier, String clientSecret, URI oidcTokenEndpoint, com.nimbusds.oauth2.sdk.Scope scope) throws SaiAuthenticationException POSTs a token request to the token endpoint of the oidcProvider using the providedclientIdentifierandclientSecretto authenticate and request the providedscope. Used for both initial token request and refresh (since the client credentials flow doesn't require refresh tokens).- Parameters:
clientIdentifier- client identifier that has been registered with the oidc providerclientSecret- client secret that has been registered with the oidc provider for the clientIdentifieroidcTokenEndpoint- token endpoint of the oidc providerscope- scope of access being requested- Returns:
- AccessToken
- Throws:
SaiAuthenticationException
-