Configure Auth. Token Header AFNetworking 2.0

I am executing the following method for my rails APIs and should send an authorization token

  def restrict_access
   authenticate_or_request_with_http_token do |token, options|
    ApiKey.exists?(access_token: token)
  end
 end

The marker works when passing through curl in a header with the format:

   -H 'Authorization: Token token = "tokenvalue"'

I find it difficult to translate this for my AFHTTPRequestOperationManager. How would I determine the following value equal to the above query?

    [self setRequestSerializer:[AFHTTPRequestSerializer serializer]];
    [self.requestSerializer setValue:@"tokenvalue" forHTTPHeaderField:@"Authorization: Token"];
+4
source share
1 answer

Finally managed to get this with

[self.requestSerializer setValue:[NSString stringWithFormat:@"Token token=101010"] forHTTPHeaderField:@"Authorization"];

Both tokens must be on the value side

+7
source

All Articles