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?
-
The URL where we can refresh an access token using a refresh token.
Declaration
Swift
public final var refreshURL: 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: Bool
-
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: Bool
-
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 thesecretInBody
setting.Declaration
Swift
public final var endpointAuthMethod: OAuth2EndpointAuthMethod
-
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]?
-
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
-
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-parameter to make the url unique, thus it will ask again for the new url.Declaration
Swift
open var safariCancelWorkaround: Bool
-
Use Proof Key for Code Exchange (PKCE)
Declaration
Swift
open var useProofKeyForCodeExchange: Bool
-
Initializer to initialize properties from a settings dictionary.
Declaration
Swift
public init(settings: OAuth2JSON)
-
Update properties from response data.
This method assumes values are present with the standard names, such as
access_token
, and assigns them to its properties.Declaration
Swift
func updateFromResponse(_ json: OAuth2JSON)
Parameters
json
JSON data returned from a request
-
Creates a dictionary of credential items that can be stored to the keychain.
Declaration
Swift
func storableCredentialItems() -> [String : Any]?
Return Value
A storable dictionary with credentials
-
Creates a dictionary of token items that can be stored to the keychain.
Declaration
Swift
func storableTokenItems() -> [String : Any]?
Return Value
A storable dictionary with token data
-
Updates receiver’s instance variables with values found in the dictionary. Returns a list of messages that can be logged on debug.
Declaration
Swift
func updateFromStorableItems(_ items: [String : Any]) -> [String]
Parameters
items
The dictionary representation of the data to store to keychain
Return Value
An array of strings containing log messages
-
Forgets the configuration’s client id and secret.
Declaration
Swift
open func forgetCredentials()
-
Forgets the configuration’s current tokens.
Declaration
Swift
open func forgetTokens()