My favorites | Sign in
Project Home Downloads Wiki Issues Source
New issue   Search
for
  Advanced search   Search tips   Subscriptions

Issue 82 attachment: oauth-timestamp.patch (2.1 KB)

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
45
46
47
48
49
50
Index: Source/OAuth/GDataOAuthAuthentication.h
===================================================================
--- Source/OAuth/GDataOAuthAuthentication.h (revision 585)
+++ Source/OAuth/GDataOAuthAuthentication.h (working copy)
@@ -77,6 +77,7 @@

NSString *realm_;
NSString *privateKey_;
+ NSTimeInterval timestampOffset_;
NSString *timestamp_; // set for testing only
NSString *nonce_; // set for testing only

@@ -94,7 +95,8 @@
//
// timestamp (seconds since 1970) and nonce (random number) are generated
// uniquely for each request, except during testing, when they may be set
-// explicitly
+// explicitly. Use timestampOffset if the server clock differs from the
+// client clock.
@property (nonatomic, copy) NSString *scope;
@property (nonatomic, copy) NSString *displayName;
@property (nonatomic, copy) NSString *hostedDomain;
@@ -110,6 +112,7 @@
@property (nonatomic, copy) NSString *verifier;
@property (nonatomic, copy) NSString *tokenSecret;
@property (nonatomic, copy) NSString *callbackConfirmed;
+@property (nonatomic, assign) NSTimeInterval timestampOffset;
@property (nonatomic, copy) NSString *timestamp;
@property (nonatomic, copy) NSString *nonce;

Index: Source/OAuth/GDataOAuthAuthentication.m
===================================================================
--- Source/OAuth/GDataOAuthAuthentication.m (revision 585)
+++ Source/OAuth/GDataOAuthAuthentication.m (working copy)
@@ -101,6 +101,7 @@
@synthesize privateKey = privateKey_;
@synthesize shouldUseParamsToAuthorize = shouldUseParamsToAuthorize_;
@synthesize userData = userData_;
+@synthesize timestampOffset = timestampOffset_;

// create an authentication object, with hardcoded values for installed apps
// of HMAC-SHA1 as signature method, and "anonymous" as the consumer key and
@@ -865,6 +866,7 @@
if (timestamp_) return timestamp_; // for testing only

NSTimeInterval timeInterval = [[NSDate date] timeIntervalSince1970];
+ timeInterval += timestampOffset_;
unsigned long long timestampVal = (unsigned long long) timeInterval;
NSString *timestamp = [NSString stringWithFormat:@"%qu", timestampVal];
return timestamp;
Powered by Google Project Hosting