@@ -36,15 +36,15 @@ - (dispatch_queue_t)methodQueue
36
36
additionalParameters: additionalParameters
37
37
resolve: resolve
38
38
reject: reject];
39
-
39
+
40
40
} else {
41
41
[OIDAuthorizationService discoverServiceConfigurationForIssuer: [NSURL URLWithString: issuer]
42
42
completion: ^(OIDServiceConfiguration *_Nullable configuration, NSError *_Nullable error) {
43
43
if (!configuration) {
44
44
reject (@" RNAppAuth Error" , [error localizedDescription ], error);
45
45
return ;
46
46
}
47
-
47
+
48
48
[self authorizeWithConfiguration: configuration
49
49
redirectUrl: redirectUrl
50
50
clientId: clientId
@@ -81,7 +81,7 @@ - (dispatch_queue_t)methodQueue
81
81
additionalParameters: additionalParameters
82
82
resolve: resolve
83
83
reject: reject];
84
-
84
+
85
85
} else {
86
86
// otherwise hit up the discovery endpoint
87
87
[OIDAuthorizationService discoverServiceConfigurationForIssuer: [NSURL URLWithString: issuer]
@@ -111,13 +111,13 @@ - (OIDServiceConfiguration *) createServiceConfiguration: (NSDictionary *) servi
111
111
NSURL *authorizationEndpoint = [NSURL URLWithString: [serviceConfiguration objectForKey: @" authorizationEndpoint" ]];
112
112
NSURL *tokenEndpoint = [NSURL URLWithString: [serviceConfiguration objectForKey: @" tokenEndpoint" ]];
113
113
NSURL *registrationEndpoint = [NSURL URLWithString: [serviceConfiguration objectForKey: @" registrationEndpoint" ]];
114
-
114
+
115
115
OIDServiceConfiguration *configuration =
116
116
[[OIDServiceConfiguration alloc ]
117
117
initWithAuthorizationEndpoint: authorizationEndpoint
118
118
tokenEndpoint: tokenEndpoint
119
119
registrationEndpoint: registrationEndpoint];
120
-
120
+
121
121
return configuration;
122
122
}
123
123
@@ -142,11 +142,11 @@ - (void)authorizeWithConfiguration: (OIDServiceConfiguration *) configuration
142
142
redirectURL: [NSURL URLWithString: redirectUrl]
143
143
responseType: OIDResponseTypeCode
144
144
additionalParameters: additionalParameters];
145
-
146
-
145
+
146
+
147
147
// performs authentication request
148
148
AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication ].delegate ;
149
-
149
+
150
150
appDelegate.currentAuthorizationFlow =
151
151
[OIDAuthState authStateByPresentingAuthorizationRequest: request
152
152
presentingViewController: appDelegate.window.rootViewController
@@ -157,7 +157,7 @@ - (void)authorizeWithConfiguration: (OIDServiceConfiguration *) configuration
157
157
} else {
158
158
reject (@" RNAppAuth Error" , [error localizedDescription ], error);
159
159
}
160
-
160
+
161
161
}]; // end [OIDAuthState authStateByPresentingAuthorizationRequest:request
162
162
}
163
163
@@ -174,7 +174,7 @@ - (void)refreshWithConfiguration: (OIDServiceConfiguration *)configuration
174
174
additionalParameters : (NSDictionary *_Nullable) additionalParameters
175
175
resolve : (RCTPromiseResolveBlock) resolve
176
176
reject : (RCTPromiseRejectBlock) reject {
177
-
177
+
178
178
OIDTokenRequest *tokenRefreshRequest =
179
179
[[OIDTokenRequest alloc ] initWithConfiguration: configuration
180
180
grantType: @" refresh_token"
@@ -186,7 +186,7 @@ - (void)refreshWithConfiguration: (OIDServiceConfiguration *)configuration
186
186
refreshToken: refreshToken
187
187
codeVerifier: nil
188
188
additionalParameters: additionalParameters];
189
-
189
+
190
190
[OIDAuthorizationService performTokenRequest: tokenRefreshRequest
191
191
callback: ^(OIDTokenResponse *_Nullable response,
192
192
NSError *_Nullable error) {
@@ -196,15 +196,17 @@ - (void)refreshWithConfiguration: (OIDServiceConfiguration *)configuration
196
196
reject (@" RNAppAuth Error" , [error localizedDescription ], error);
197
197
}
198
198
}];
199
-
199
+
200
200
}
201
201
202
202
/*
203
203
* Take raw OIDTokenResponse and turn it to a token response format to pass to JavaScript caller
204
204
*/
205
205
- (NSDictionary *)formatResponse : (OIDTokenResponse*) response {
206
206
NSDateFormatter *dateFormat = [[NSDateFormatter alloc ] init ];
207
- [dateFormat setDateFormat: @" yyyy-MM-dd'T'HH:mm:ssZ" ];
207
+ dateFormat.timeZone = [NSTimeZone timeZoneWithAbbreviation: @" UTC" ];
208
+ [dateFormat setLocale: [NSLocale localeWithLocaleIdentifier: @" en_US_POSIX" ]];
209
+ [dateFormat setDateFormat: @" yyyy-MM-dd'T'HH:mm:ss'Z'" ];
208
210
209
211
return @{@" accessToken" : response.accessToken ? response.accessToken : @" " ,
210
212
@" accessTokenExpirationDate" : response.accessTokenExpirationDate ? [dateFormat stringFromDate: response.accessTokenExpirationDate] : @" " ,
0 commit comments