-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathAFNetworking+ApiKeyAuthentication.m
44 lines (29 loc) · 1.3 KB
/
AFNetworking+ApiKeyAuthentication.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//
// AFNetworking+ApiKeyAuthentication.m
//
// Created by Richard Fung on 2/21/13.
// Copyright (c) 2013. MIT License.
//
#import "AFNetworking+ApiKeyAuthentication.h"
@implementation AFHTTPClient(TastyPie)
- (void)setAuthorizationHeaderWithTastyPieUsername:(NSString*) username andToken:(NSString *)token{
// refer to http://django-tastypie.readthedocs.org/en/latest/authentication_authorization.html
// for details
NSString* strApiKey = [NSString stringWithFormat:@"ApiKey %@:%@", username, token];
[self setDefaultHeader:@"Authorization" value:strApiKey];
}
@end
@implementation NSMutableURLRequest(TastyPie)
- (void)setAuthorizationHeaderWithTastyPieUsername:(NSString*) username andToken:(NSString *)token{
NSString* strApiKey = [NSString stringWithFormat:@"ApiKey %@:%@", username, token];
[self setValue:strApiKey forHTTPHeaderField:@"Authorization"];
}
@end
@implementation AFHTTPRequestOperation(TastyPie)
- (void)setAuthorizationHeaderWithTastyPieUsername:(NSString*) username andToken:(NSString *)token{
// refer to http://django-tastypie.readthedocs.org/en/latest/authentication_authorization.html
// for details
NSString* strApiKey = [NSString stringWithFormat:@"ApiKey %@:%@", username, token];
[self setValue:strApiKey forHTTPHeaderField:@"Authorization"];
}
@end