OAuth2ClientCredentialsAuthenticationParameters

public struct OAuth2ClientCredentialsAuthenticationParameters

A wrapper for the expected input parameters for the OAuth2 Client Credentials Grant.

  • This URL has the functionality to exchange OAuth 2.0 Client Credentials Grant for an OAuth 2.0 token.

    Declaration

    Swift

    public let tokenEndpointURL: URL
  • Set of scopes that the client should request.

    Declaration

    Swift

    public let requestingScopes: Set<String>
  • This block is invoked before the token request is sent. You can implement custom authorization methods if the token endpoint requires it.

    Declaration

    Swift

    public let clientCredentialsHandler: (URLRequest) throws -> URLRequest
  • Authentication parameters for the Client Credentials Grant.

    Declaration

    Swift

    public init(tokenEndpointURL: URL, requestingScopes: Set<String> = [], clientCredentialsHandler: @escaping (URLRequest) throws -> URLRequest)

    Parameters

    tokenEndpointURL

    This URL has the functionality to exchange OAuth 2.0 Client Credentials Grant for a OAuth 2.0 token.

    requestingScopes

    Set of scopes that the client should request.

    clientCredentialsHandler

    This block is invoked before the token request is sent. You can implement custom authorization methods if the token endpoint requires it.

  • Authentication parameters for the Client Credentials Grant.

    Throws

    OAuth2Error.invalidArgument if the basic authentication string cannot be created.

    Declaration

    Swift

    public init(tokenEndpointURL: URL, requestingScopes: Set<String> = [], name: String, secret: String)

    Parameters

    tokenEndpointURL

    This URL has the functionality to exchange OAuth 2.0 Client Credentials Grant for a OAuth 2.0 token.

    requestingScopes

    Set of scopes that the client should request.

    name

    the user name

    secret

    the user secret

  • Instantiates the OAuth2ClientCredentialsAuthenticationParameters from the SAP Cloud Platform configuration object. The configuration object is expected in the following format:

    let configuration: [String: String] = [
        "tokenEndpointURL": "<#token endpoint URL string#>",
        "scope": "<#scope#>", // Optional, structure described at https://tools.ietf.org/html/rfc6749#section-3.3
        "kState": "<#state#>"
        "name": "<#name#>",
        "secret": "<#secret#>"
    ]
    

    The URL strings are converted to URL using the URL object’s string initializer. If the initializer returns nil, an error is raised.

    Throws

    ConfigurationError if the configuration is not matching.

    Declaration

    Swift

    public init(discoveryServiceConfig config: Any) throws

    Parameters

    config

    The SAP Cloud Platform configuration object