URLRequest - daneden/Twift GitHub Wiki
Extensions on URLRequest
Methods
oAuthSign(method:urlFormParameters:consumerCredentials:userCredentials:)
Easy to use method to sign a URLRequest which includes url-form parameters with OAuth. The request needs a valid URL with all query parameters etc. included. After calling this method the HTTP header fields: "Authorization", "Content-Type" and "Content-Length" should not be overwritten.
mutating func oAuthSign(method: String, urlFormParameters paras: [String: String],
consumerCredentials cc: OAuthHelper.Credentials, userCredentials uc: OAuthHelper.Credentials? = nil)
Parameters
- method: HTTP Method
- paras: url-form parameters
- consumerCredentials: consumer credentials
- userCredentials: user credentials (nil if this is a request without user association)
oAuthSign(method:body:contentType:consumerCredentials:userCredentials:)
Easy to use method to sign a URLRequest which includes plain body data with OAuth. The request needs a valid URL with all query parameters etc. included. After calling this method the HTTP header fields: "Authorization", "Content-Type" and "Content-Length" should not be overwritten.
mutating func oAuthSign(method: String, body: Data? = nil, contentType: String? = nil,
consumerCredentials cc: OAuthHelper.Credentials, userCredentials uc: OAuthHelper.Credentials? = nil)
Parameters
- method: HTTP Method
- body: HTTP request body (default: nil)
- contentType: HTTP header "Content-Type" entry (default: nil)
- consumerCredentials: consumer credentials
- userCredentials: user credentials (nil if this is a request without user association)