OAuth2Requestable
open class OAuth2Requestable
Abstract base class for OAuth2 authorization as well as client registration classes.
-
Set to
trueto log all the things.falseby default. Use"verbose": boolin settings or assignloggeryourself.Declaration
Swift
open var verbose = false -
The logger being used. Auto-assigned to a debug logger if you set
verboseto true or false.Declaration
Swift
open var logger: OAuth2Logger? -
Base initializer.
Declaration
Swift
public init(verbose: Bool) -
Designated initializer.
Declaration
Swift
public init(logger: OAuth2Logger?)Parameters
loggerAn optional
OAuth2Loggerinstance to use
-
The instance’s current session, creating one by the book if necessary. Defaults to using an ephemeral session, you can use
sessionConfigurationand/orsessionDelegateto affect how the session is configured.Declaration
Swift
open var session: URLSession -
The configuration to use when creating
session. Uses an+ephemeralSessionConfiguration()if nil.Declaration
Swift
open var sessionConfiguration: URLSessionConfiguration? -
URL session delegate that should be used for the
NSURLSessionthe instance uses for requests.Declaration
Swift
open var sessionDelegate: URLSessionDelegate? -
The instance’s OAuth2RequestPerformer, defaults to using OAuth2DataTaskRequestPerformer which uses
URLSession.dataTask().Declaration
Swift
open var requestPerformer: OAuth2RequestPerformer? -
Perform the supplied request and call the callback with the response JSON dict or an error. This method is intended for authorization calls, not for data calls outside of the OAuth2 dance.
This implementation uses the shared
NSURLSessionand executes a data task. If the server responds with an error, this will be converted into an error according to information supplied in the response JSON (if availale).The callback returns a response object that is easy to use, like so:
perform(request: req) { response in do { let data = try response.responseData() // do what you must with `data` as Data and `response.response` as HTTPURLResponse } catch let error { // the request failed because of `error` } }Easy, right?
Declaration
Swift
open func perform(request: URLRequest, callback: @escaping ((OAuth2Response) -> Void))Parameters
requestThe request to execute
callbackThe callback to call when the request completes/fails. Looks terrifying, see above on how to use it
-
Parse string-only JSON from NSData.
Declaration
Swift
open func parseJSON(_ data: Data) throws -> OAuth2JSONParameters
dataNSData returned from the call, assumed to be JSON with string-values only.
Return Value
An OAuth2JSON instance
-
Parse a query string into a dictionary of String: String pairs.
If you’re retrieving a query or fragment from NSURLComponents, use the
percentEncoded##variant as the others automatically perform percent decoding, potentially messing with your query string.Declaration
Swift
public final class func params(fromQuery query: String) -> OAuth2StringDictParameters
fromQueryThe query string you want to have parsed
Return Value
A dictionary full of strings with the key-value pairs found in the query
View on GitHub
Install in Dash
OAuth2Requestable Class Reference