Sebastian Boldt
Sebastian Boldt

Reputation: 5321

AFHTTPClient sets Authorization Header Field like " Token token='\75845hjhrtje845395748' " But i just want to be the token inside

I am currently trying to implement authorization with AFNetworking. I tried to put the access_token inside the HTTP-Authorizationheader. But what arrives at the server is like :

Token token  = "\fdasfjhalsfh4546" 

It should be just the token-value inside the Header. My Code looks like this :

- (void)setAuthTokenHeader {
    CredentialStore *store = [[CredentialStore alloc] init];
    [self setAuthorizationHeaderWithToken:[store authToken]];
}

[store authToken] just returns the authtoken itself, so I don't understand why the HTTP-Field-Content looks like this?

Upvotes: 3

Views: 2193

Answers (1)

Sebastian Boldt
Sebastian Boldt

Reputation: 5321

The Problem is way easier then i thought. It seems that Afnetworking appends the token by default to that string :

- (void)setAuthorizationHeaderWithToken:(NSString *)token {
    [self setDefaultHeader:@"Authorization" value:[NSString stringWithFormat:@"Token token=\"%@\"", token]];
}

Upvotes: 4

Related Questions