I'm following the following method to my rails API, and need to send in an authorization token
def restrict_access
authenticate_or_request_with_http_token do |token, options|
ApiKey.exists?(access_token: token)
end
end
The token works when passing in via curl in a header with format:
-H 'Authorization: Token token = "tokenvalue"'
I'm having trouble translating this for my AFHTTPRequestOperationManager. How would I define the below to equal the above curl request ?
[self setRequestSerializer:[AFHTTPRequestSerializer serializer]];
[self.requestSerializer setValue:@"tokenvalue" forHTTPHeaderField:@"Authorization: Token"];
Was finally able to get this with:
[self.requestSerializer setValue:[NSString stringWithFormat:@"Token token=101010"] forHTTPHeaderField:@"Authorization"];
Both tokens needs to be on the value side
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With