-
Notifications
You must be signed in to change notification settings - Fork 278
Dropbox
Pascal Pfiffner edited this page Jun 26, 2018
·
1 revision
Dropbox returns a 400
error if no Authorization
header is present, rather than a 401
. This means the interceptor cannot intercept such a response and attempt an authorization. The best workaround is to add a fake Authorization
header if the data loader is to be used or simply do manual authorization.
Example code, courtesy of @salexkidd: https://github.com/p2/OAuth2/pull/270#issuecomment-398996766
func postRequest(path: String, callback: @escaping ((OAuth2JSON?, Error?) -> Void)) {
let url = baseURL.appendingPathComponent(path)
var req = oauth2.request(forURL: url)
req.httpMethod = "POST"
req.addValue("application/json", forHTTPHeaderField: "Content-type")
if req.value(forHTTPHeaderField: "Authorization") == nil {
req.setValue("Bearer 0000", forHTTPHeaderField: "Authorization")
}
...
}