Token Requests
Requesting tokens from your OIDC provider
We saw in our example that the OIDCProvider class has a method called requestToken
, which is used to request tokens from the provider.
This method takes a TokenRequest
object as a parameter, which is class with a number of properties, including:
grantType
- the grant type being used e.g.authorization_code
,client_credentials
,refresh_token
code
- the authorization code you have received from the authorization server, for authorization code grantsredirectUri
- the redirect URI, for authorization code grantsscopes
- the scopes you are requestingrefreshToken
- the refresh token, for refresh token grantsclientAuthentication
- a necessary abstraction to allow for different client authentication methods, most of which deal with networking protocols of some sort
This class, like most of the domain objects in the library, comes with a Builder class to facilitate flowing construction of the object.
Passing this object to the requestToken
method will return a TokenResponse
object, which contains the tokens you have requested. All the
validation and processing of this takes place within the library, although you may wish to perform some validation of your own.