Skip to content

Instantly share code, notes, and snippets.

@Juanpe
Created March 24, 2019 13:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Juanpe/e877f96aaaac1c7e1c122dd6e96ca80c to your computer and use it in GitHub Desktop.
Save Juanpe/e877f96aaaac1c7e1c122dd6e96ca80c to your computer and use it in GitHub Desktop.
class OAuth2Handler: RequestAdapter {
func adapt(_ urlRequest: URLRequest) throws -> URLRequest {
guard let token = authenticator.bearer
else { return urlRequest }
var mutableURLRequest = urlRequest
mutableURLRequest.setValue("Bearer " + token, forHTTPHeaderField: "Authorization")
return mutableURLRequest
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment