@@ -153,7 +153,7 @@ - (BOOL) _configureProvider:(NSString *)providerName andConfig:(NSDictionary *)c
153
153
_callbackUrls = [arr copy ];
154
154
NSLog (@" Saved callback url: %@ in %@ " , saveCallbackUrl, _callbackUrls);
155
155
}
156
-
156
+
157
157
158
158
// Convert objects of url type
159
159
for (NSString *name in [config allKeys ]) {
@@ -354,14 +354,14 @@ - (NSDictionary *) getConfigForProvider:(NSString *)name
354
354
355
355
[manager addPending: client];
356
356
_pendingAuthentication = YES ;
357
-
357
+
358
358
NSLog (@" Calling authorizeWithUrl: %@ with callbackURL: %@ \n %@ " , providerName, callbackUrl, cfg);
359
359
360
360
[client authorizeWithUrl: providerName
361
361
url: callbackUrl
362
362
cfg: cfg
363
363
onSuccess: ^(DCTAuthAccount *account) {
364
- NSLog (@" on success called with account: %@ " , account);
364
+ NSLog (@" on success called with account: %@ " , account);
365
365
NSDictionary *accountResponse = [manager getAccountResponse: account cfg: cfg];
366
366
_pendingAuthentication = NO ;
367
367
[manager removePending: client];
@@ -444,21 +444,26 @@ - (NSDictionary *) getConfigForProvider:(NSString *)name
444
444
items: items];
445
445
446
446
// Allow json body in POST / PUT requests
447
-
448
447
NSDictionary *body = [opts objectForKey: @" body" ];
449
448
if (body != nil ) {
450
- /* for (NSString *key in body) {
449
+ NSMutableArray *items = [NSMutableArray array ];
450
+
451
+ for (NSString *key in body) {
451
452
NSString *value = [body valueForKey: key];
452
453
453
- if(value != nil) {
454
- [request.content.HTTPBody addObject:];
454
+ DCTAuthContentItem *item = [[DCTAuthContentItem alloc ] initWithName: key value: value];
455
+
456
+ if (item != nil ) {
457
+ [items addObject: item];
455
458
}
456
- }*/
457
- [request.content setHTTPBody: body];
459
+ }
460
+
461
+ DCTAuthContent *content = [[DCTAuthContent alloc ] initWithEncoding: NSUTF8StringEncoding
462
+ type: DCTAuthContentTypeJSON
463
+ items: items];
464
+ [request setContent: content];
458
465
}
459
466
460
- request.account = existingAccount;
461
-
462
467
// If there are headers
463
468
NSDictionary *headers = [opts objectForKey: @" headers" ];
464
469
if (headers != nil ) {
@@ -469,6 +474,8 @@ - (NSDictionary *) getConfigForProvider:(NSString *)name
469
474
request.HTTPHeaders = existingHeaders;
470
475
}
471
476
477
+ request.account = existingAccount;
478
+
472
479
[request performRequestWithHandler: ^(DCTAuthResponse *response, NSError *error) {
473
480
if (error != nil ) {
474
481
NSDictionary *errorDict = @{
@@ -493,10 +500,9 @@ - (NSDictionary *) getConfigForProvider:(NSString *)name
493
500
494
501
// Parse XML
495
502
data = [XMLReader dictionaryForXMLData: rawData
496
- options: XMLReaderOptionsProcessNamespaces
497
- error: &err];
503
+ options: XMLReaderOptionsProcessNamespaces
504
+ error: &err];
498
505
}
499
-
500
506
if (err != nil ) {
501
507
NSDictionary *errResp = @{
502
508
@" status" : @" error" ,
@@ -506,7 +512,7 @@ - (NSDictionary *) getConfigForProvider:(NSString *)name
506
512
} else {
507
513
NSDictionary *resp = @{
508
514
@" status" : @(statusCode),
509
- @" data" : data
515
+ @" data" : data != nil ? data : @[]
510
516
};
511
517
callback (@[[NSNull null ], resp]);
512
518
}
@@ -533,7 +539,7 @@ - (DCTAuthAccount *) accountForProvider:(NSString *) providerName
533
539
}
534
540
535
541
- (NSDictionary *) credentialForAccount : (NSString *)providerName
536
- cfg : (NSDictionary *)cfg
542
+ cfg : (NSDictionary *)cfg
537
543
{
538
544
DCTAuthAccount *account = [self accountForProvider: providerName];
539
545
if (!account) {
@@ -721,3 +727,4 @@ - (NSString *) stringHost:(NSURL *)url
721
727
}
722
728
723
729
@end
730
+
0 commit comments