Server Smalltalk Guide : OAuth2.0 and OpenID Connect : SstOAuth2AuthorizationCodeGrant
SstOAuth2AuthorizationCodeGrant
This class implements the Authorization Code grant type for OAuth2.0.
Class Methods
newWithClientId:authorizationBaseUrl:tokenUrl:
  Create the 'Authorization Code' grant which can be used to create the authorization URL (to which to redirect the user) and subsequently create a client with the necessary authorization code.
     
     Arguments:
        clientId: <String> the id of the registered client
        authorizationUrl: <SstUrl> the base authorization endpoint URL as specified by the service
        tokenUrl: <SstUrl> the access token endpoint URL as specified by the service
    
     Answers:
        <SstOauth2AuthorizationCodeGrant> 
Instance Methods
addAuthorizationParameter:value:
  Add an additional url query parameter with key <key> and value <value> to be included in the authorization URL. 
     It is not allowed to use a key that is an existing OAuth2 protocol query parameter, which is under control by this client.
     Values for 'state', 'scope', 'client_id', etc... should be set via the appropriate accessors.
     
     Arguments:
        key - <String>
        value- <String>
    Raises:
        SstOAuth2Error when a reserved authorization parameter is passed.
addAuthorizationParameters:
  Add additional url query parameters (key-value pairs of Strings) to be included in the authorization URL. 
     It is not allowed to use a key that is an existing OAuth2 protocol query parameter, which is under control by this client.
     Values for 'state', 'scope', 'client_id', etc... should be set via the appropriate accessors.
     
     Arguments:
        aKeyedCollection - <KeyedCollection> containing the key-value pairs of which both the key and the value are a <String>.
    Raises:
        SstOAuth2Error when a reserved authorization parameter is passed.
authorizationBaseUrl
  Return the authorization endpoint url as it was provided on instance creation
     
     Answers:
        <SstUrl>
authorizationUrlWithRedirectTo:state:
  Returns the URL that the user should be redirected to for authorization, as per https://datatracker.ietf.org/doc/html/rfc6749#section-4.2.1.
     This method can only be called once.
     
     Arguments:
        aRedirectUrlOrNil - <SstUrl> that the user will de redirected to after performing authorization or <nil> when no redirect is expected
        stateStringOrNil - <String> or <nil> when no state parameter is to be sent (not recommended)
    
     Answers:
        <SstUrl>
createClientFromAuthorizationResponseData:
  When successful, returns the OAuth2 https client (i.e. using schemeId httpsl) that can be used to make API calls on the protected resources.
     A client can be created only once from the same receiver.
     
     Arguments:
        queryParameters - <KeyedCollection> with the key/value pairs representing the data that was passed via the redirect url query parameters in the redirection request following authorization
     Answers:
        <SstOAuth2HttpClient>
    Raises:
        <SstOAuth2Error>
createClientFromAuthorizationResponseData:withTransportScheme:
  When successful, returns the OAuth2 http client (with the provided schemeId) that can be used to make API calls on the protected resources.
     A client can be created only once from the same receiver.
     
     Arguments:
        queryParameters - <KeyedCollection> with the key/value pairs representing the data that was passed via the redirect url query parameters in the redirection request following authorization
        schemeId - <String>
     Answers:
        <SstOAuth2HttpClient>
    Raises:
        <SstOAuth2Error>
createClientFromAuthorizationResponseUrl:
  When successful, returns the OAuth2 https client (i.e. using schemeId httpsl) that can be used to make API calls on the protected resources. 
     A client can be created only once from the same receiver.
     
     Arguments:
        responseUrl - <SstUrl> to which the user was redirected after performing authorization
     Answers:
        <SstOAuth2HttpClient>
    Raises:
        <SstOAuth2Error>
createClientFromAuthorizationResponseUrl:withTransportScheme:
  When successful, returns the OAuth2 http client (with the provided schemeId) that can be used to make API calls on the protected resources. 
     A client can be created only once from the same receiver.
     
     Arguments:
        responseUrl - <SstUrl> to which the user was redirected after performing authorization
        schemeId - <String>
     Answers:
        <SstOAuth2HttpClient>
    Raises:
        <SstOAuth2Error>
startAuthorization:withCallbackAt:state:
  Convenience method that returns a <Future> that will resolve when the authorization process completes.
     
     The authorizationSetupBlock is expected to be a two-argument block that will be executed immediately to redirect the user to authorization URL of the service. 
     It should also setup the necessary infrastructure to capture the redirect performed by the authorization service to the applicationCallbackUrl.
    The first argument passed to the block is the authorization URL (<SstUrl>) to which the user should be sent to obtain authorization.
    The second argument passed to the block is a <Block> that must be invoked with the <SstUrl> to which the user was redirected after authenticating with the service as argument.
     
    Arguments:
        authorizationSetupBlock: two-argument <Block> (explained above)
        applicationCallbackUrl: a <SstUrl> to where the authorization server should redirect the user after the authorization process (i.e. where the result of the authorization process will be processed).
    
    Answers:
        <Future>    that will resolve to a <OAuth2Httpclient> on successful authorization, or an <Error> when failed.
state
  Return the state parameter value as it was provided when the authorization request was initiated.
     
     Answers:
        <String>
Last modified date: 01/09/2026