OAuth2ClientConfig

open class OAuth2ClientConfig

Client configuration object that holds on to client-server specific configurations such as client id, -secret and server URLs.

  • The client id.

    Declaration

    Swift

    public final var clientId: String?
  • The client secret, usually only needed for code grant.

    Declaration

    Swift

    public final var clientSecret: String?
  • The name of the client, e.g. for use during dynamic client registration.

    Declaration

    Swift

    public final var clientName: String?
  • The URL to authorize against.

    Declaration

    Swift

    public final let authorizeURL: URL
  • The URL where we can exchange a code for a token.

    Declaration

    Swift

    public final var tokenURL: URL?
  • Where a logo/icon for the app can be found.

    Declaration

    Swift

    public final var logoURL: URL?
  • The scope currently in use.

    Declaration

    Swift

    open var scope: String?
  • The redirect URL string currently in use.

    Declaration

    Swift

    open var redirect: String?
  • All redirect URLs passed to the initializer.

    Declaration

    Swift

    open var redirectURLs: [String]?
  • The receiver’s access token.

    Declaration

    Swift

    open var accessToken: String?
  • The receiver’s id token. Used by Google + and AWS Cognito

    Declaration

    Swift

    open var idToken: String?
  • The access token’s expiry date.

    Declaration

    Swift

    open var accessTokenExpiry: Date?
  • If set to true (the default), uses a keychain-supplied access token even if no expires_in parameter was supplied.

    Declaration

    Swift

    open var accessTokenAssumeUnexpired = true
  • The receiver’s long-time refresh token.

    Declaration

    Swift

    open var refreshToken: String?
  • The URL to register a client against.

    Declaration

    Swift

    public final var registrationURL: URL?
  • Whether the receiver should use the request body instead of the Authorization header for the client secret; defaults to false.

    Declaration

    Swift

    public var secretInBody = false
  • How the client communicates the client secret with the server. Defaults to .None if there is no secret, .clientSecretPost if secret_in_body is true and .clientSecretBasic otherwise. Interacts with the secretInBody setting.

    Declaration

    Swift

    public final var endpointAuthMethod = OAuth2EndpointAuthMethod.none
  • Contains special authorization request headers, can be used to override defaults.

    Declaration

    Swift

    open var authHeaders: OAuth2Headers?
  • Add custom parameters to the authorization request.

    Declaration

    Swift

    public var customParameters: [String: String]? = nil
  • Most servers use UTF-8 encoding for Authorization headers, but that’s not 100% true: make it configurable (see https://github.com/p2/OAuth2/issues/165).

    Declaration

    Swift

    open var authStringEncoding = String.Encoding.utf8
  • There’s an issue with authenticating through ‘system browser’, where safari says: Safari cannot open the page because the address is invalid. if you first selects ‘Cancel’ when asked to switch back to your app, and then you try authenticating again. To get rid of it you must restart Safari.

    Read more about it here: http://stackoverflow.com/questions/27739442/ios-safari-does-not-recognize-url-schemes-after-user-cancels https://community.fitbit.com/t5/Web-API/oAuth2-authentication-page-gives-me-a-quot-Cannot-Open-Page-quot-error/td-p/1150391

    Toggling safariCancelWorkaround to true will send an extra get-paramter to make the url unique, thus it will ask again for the new url.

    Declaration

    Swift

    open var safariCancelWorkaround = false
  • Initializer to initialize properties from a settings dictionary.

    Declaration

    Swift

    public init(settings: OAuth2JSON)
  • Forgets the configuration’s client id and secret.

    Declaration

    Swift

    open func forgetCredentials()
  • Forgets the configuration’s current tokens.

    Declaration

    Swift

    open func forgetTokens()