Iโm trying to get messages list from gmail on iOS. I successfully received access token (using OAuth 2.0) to my account. But the next i have to do is get messages list using exactly AFNetworking framework (thatโs the aim). Tried to do everything i could just like here: Google API Users.messages: list but i got an error :
Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: forbidden (403)" UserInfo=0x8e5f9b0 {com.alamofire.serialization.response.error.response= { URL: .../gmail/v1/users/me/messages } { status code: 403, headers {
"Alternate-Protocol" = "443:quic,p=1";
"Cache-Control" = "private, max-age=0";
"Content-Encoding" = gzip;
"Content-Type" = "application/json; charset=UTF-8";
Date = "Tue, 28 Jul 2015 10:54:07 GMT";
Expires = "Tue, 28 Jul 2015 10:54:07 GMT";
Server = GSE;
"Transfer-Encoding" = Identity;
Vary = "Origin, X-Origin";...
Here is my code:
#import "RSServerManager.h"
#import "AFNetworking.h"
#import "RSUser.h"
#import "RSAccessToken.h"
#interface RSServerManager()
#property (strong, nonatomic) AFHTTPRequestOperationManager *requestOperationManager;
#end
#implementation RSServerManager
+ (RSServerManager *) sharedManager {
static RSServerManager *manager = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
manager = [[RSServerManager alloc] init];
});
return manager;
}
- (id)init
{
self = [super init];
if (self) {
NSURL *url = [NSURL URLWithString:#"https://www.googleapis.com/"];
self.requestOperationManager = [[AFHTTPRequestOperationManager alloc] initWithBaseURL:url];
}
return self;
}
GET method:
- (void) getMessagesList:(RSAccessToken *)accessToken
onSuccess:(void (^)(__autoreleasing id *))success
onFailure:(void (^)(NSError *, NSInteger))failure {
NSDictionary *Parameters = [NSDictionary dictionaryWithObjectsAndKeys:
#"messages", #"fields",
#"true", #"includeSpamTrash",
#"https://mail.google.com/", #"scope",
#"query", #"q",nil];
AFHTTPRequestSerializer *requestSerializer = [AFJSONRequestSerializer serializer];
NSString *authValue = [NSString stringWithFormat:#"Bearer %#", accessToken.access_token];
[requestSerializer setValue: authValue forHTTPHeaderField:#"Authorization"];
[requestSerializer setValue:#"application/json" forHTTPHeaderField:#"Content-Type"];
self.requestOperationManager.requestSerializer = requestSerializer;
[self.requestOperationManager
GET:#"gmail/v1/users/me/messages"
parameters: Parameters
success:^(AFHTTPRequestOperation *operation, NSDictionary *responseObject) {
NSLog(#"JSON : %#", responseObject);
if (success) {
success(nil);
}
}
failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(#"Error: %#", error);
if (failure) {
failure(error, operation.response.statusCode);
}
}];
}
Please help me to find the correct way to get these message list using AFNetworking!!!
Enable Gmail-API in your developers console. Include one of the scopes mentioned in this link in your code.
Related
I have a server with OAuth 2.0 implemented for issuing access and refresh tokens. The client for this server is an iOS App written in Objective-C. I am currently using AFNetworking 3.0 for HTTP requests and AFOAuth2Manager to handle authorization. I want to refresh my access token stored in iOS app using the refresh token issued by the server before the access token expires (server returns number of seconds to expire as { 'expires_in': 3600 } (one hour)). Everything is working fine until the access token expires. Below is my code for handling requests and authorization.
- (AFJSONRequestSerializer *)setRequestSerializer
{
AFJSONRequestSerializer *serializer = [AFJSONRequestSerializer serializer];
[serializer setValue:#"application/json" forHTTPHeaderField:#"Content-Type"];
[serializer setValue:#"application/json" forHTTPHeaderField:#"Accept"];
User *currentUser = [User currentUser];
if (currentUser){
AFOAuthCredential *credentials = [AFOAuthCredential retrieveCredentialWithIdentifier:kEndpointServer];
if (!credentials.isExpired){
[serializer setAuthorizationHeaderFieldWithCredential:credentials];
}
}
return serializer;
}
- (AFJSONResponseSerializer *)setResponseSerializer
{
AFJSONResponseSerializer *serializer = [AFJSONResponseSerializer serializer];
return serializer;
}
- (AFSecurityPolicy *)setSecurityPolicy
{
NSString *certFilePath = [[NSBundle mainBundle] pathForResource:#"cert" ofType:#"cer"];
NSData *certData = [NSData dataWithContentsOfFile:certFilePath];
NSSet *pinnedCerts = [NSSet setWithObject:certData];
AFSecurityPolicy *policy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeCertificate withPinnedCertificates:pinnedCerts];
[policy setAllowInvalidCertificates:YES]; // DEVELOPMENT ONLY
[policy setValidatesDomainName:NO];
return policy;
}
- (AFHTTPSessionManager *)sessionManager
{
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
manager.securityPolicy = [self setSecurityPolicy];
manager.requestSerializer = [self setRequestSerializer];
manager.responseSerializer = [self setResponseSerializer];
return manager;
}
- (AFOAuth2Manager *)OAuth2Manager
{
NSURL *baseURL = [NSURL URLWithString:kEndpointServer];
AFOAuth2Manager *manager = [[AFOAuth2Manager alloc] initWithBaseURL:baseURL clientID:kParamAPIClientId secret:kParamAPIClientSecret];
manager.securityPolicy = [self setSecurityPolicy];
return manager;
}
- (void)loginUser:(NSDictionary *)user block:(void (^)(BOOL, NSError *))result
{
// Set endpoint URL
NSString *loginEndpointURL = [NSString stringWithFormat:#"%#%#", kEndpointServer, kEndpointLogin];
AFHTTPSessionManager *manager = [self sessionManager];
if ([self internetConnectionAvailable]){
[manager POST:loginEndpointURL parameters:user progress:nil success:^(NSURLSessionDataTask *task, id responseObject){
NSDictionary *responseDict = (NSDictionary *)responseObject;
BOOL success = (BOOL)[(NSNumber *)[responseDict objectForKey:kParamSuccess] boolValue];
NSString *msg = (NSString *)[responseDict objectForKey:kParamMessage];
if (success){
// Get user
NSDictionary *userLoggedIn = (NSDictionary *)[responseDict objectForKey:kParamUser];
//NSLog(#"Logged in.");
NSString *tokenEndpointURL = [NSString stringWithFormat:#"/api%#%#", kEndpointOAuth, kEndpointToken];
OAuth2Manager *OAuth2Manager = [self OAuth2Manager];
[OAuth2Manager authenticateUsingOAuthWithURLString:tokenEndpointURL username:(NSString *)[user objectForKey:kParamEmail] password:(NSString *)[user objectForKey:kParamPassword] scope:nil success:^(AFOAuthCredential *credentials){
NSLog(#"Credentials:");
NSLog(#"Access Token: %#", credentials.accessToken);
NSLog(#"Refresh Token: %#", credentials.refreshToken);
// Store credentials
[AFOAuthCredential storeCredential:credentials withIdentifier:kEndpointServer];
// Set current user
[User setCurrentUser:userLoggedIn];
result(YES, nil);
}failure:^(NSError *error){
NSLog(#"Error authenticating user: %#", error);
result(NO, error);
}];
} else {
result(NO, [NSError errorWithDomain:msg code:kEDHTTPRequestFailedErrorCode userInfo:nil]);
}
}failure:^(NSURLSessionDataTask *task, NSError *error){
result(NO, error);
}];
} else {
result(NO, [NSError errorWithDomain:kEDNoInternetConnectionErrorDomain code:kEDNoInternetConnectionErrorCode userInfo:nil]);
}
}
I have found a similar question on SO:
How to automatically refresh expired token with AFOAuth2Manager?
But the problem with the answer given is that it is outdated (Works with AFNetworking 2.X.X, but does not work with AFNetworking 3.0).
What is the best practice for handling the refreshing of the access token automatically?
I am trying to call a POST API on Instagram using AFNetworking, and my code to call is:
void (^mySuccessBlock)(AFHTTPRequestOperation *operation, id responseObject) = ^(AFHTTPRequestOperation *operation, id responseObject) {
NSDictionary* userInfo = (NSDictionary*) responseObject;
if (block != nil) {
block(userInfo, nil);
}
};
void (^failureBlock)(AFHTTPRequestOperation *operation, NSError *error) = ^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(#"Request Error: %#", error);
if (block != nil) {
block(nil, error);
}
};
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.requestSerializer = [AFJSONRequestSerializer serializer];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSMutableDictionary *param=[[NSMutableDictionary alloc]init];
NSString * token =[defaults objectForKey:ACCESS_TOKEN];
[param setValue:token forKey:#"access_token"];
NSString *url=[NSString stringWithFormat:#"https://api.instagram.com/v1/media/%#/likes" , globalMediaId];
[manager POST:url parameters:param success:mySuccessBlock failure:failureBlock ];
But I am getting this error:
request Error: Error Domain=com.alamofire.error.serialization.response
Code=-1011 "Request failed: bad request (400)" UserInfo=0x7fb4c9698e00
{com.alamofire.serialization.response.error.response= { URL:
https://api.instagram.com/v1/media/853150485752748330_1509614005/likes
} { status code: 400, headers {
"Cache-Control" = "private, no-cache, no-store, must-revalidate";
Connection = "keep-alive";
"Content-Language" = en;
"Content-Length" = 114;
"Content-Type" = "application/json; charset=utf-8";
Date = "Mon, 29 Jun 2015 05:55:33 GMT";
Expires = "Sat, 01 Jan 2000 00:00:00 GMT";
Pragma = "no-cache";
"Set-Cookie" = "csrftoken=f4b5426f69b154c60e6785ba52100a09; expires=Mon, 27-Jun-2016 05:55:33 GMT; Max-Age=31449600; Path=/";
Vary = "Cookie, Accept-Language"; } }, NSErrorFailingURLKey=https://api.instagram.com/v1/media/853150485752748330_1509614005/likes,
com.alamofire.serialization.response.error.data=<7b226d65 7461223a
7b226572 726f725f 74797065 223a224f 41757468 50617261 6d657465
72457863 65707469 6f6e222c 22636f64 65223a34 30302c22 6572726f
725f6d65 73736167 65223a22 4d697373 696e6720 61636365 73735f74
6f6b656e 2055524c 20706172 616d6574 65722e22 7d7d>,
NSLocalizedDescription=Request failed: bad request (400)}
Does anyone know why I'm getting this?
I want to use the Instagram API, and I downloaded this project from link, But I can't Post a Request to the server, it always gets the following error :
Error Domain=AFNetworkingErrorDomain Code=-1011 "Request failed: forbidden (403)" UserInfo=0x79eb1330 {NSErrorFailingURLKey=https://api.instagram.com/.../950394368622277294.../likes, AFNetworkingOperationFailingURLResponseErrorKey=<NSHTTPURLResponse: 0x7a12c8c0> { URL: https://api.instagram.com/.../950394368622277294.../likes } { status code: 403, headers {
"Cache-Control" = "private, no-cache, no-store, must-revalidate";
Connection = "keep-alive";
"Content-Language" = en;
"Content-Length" = 143;
"Content-Type" = "application/json";
Date = "Sat, 28 Mar 2015 10:07:53 GMT";
Expires = "Sat, 01 Jan 2000 00:00:00 GMT";
Pragma = "no-cache";
Server = nginx;
Vary = "Accept-Language, Cookie";
"X-Instagram-Ssl-Wifi" = False;
} }, NSLocalizedDescription=Request failed: forbidden (403)}
when calling this method:
- (void)postPath:(NSString *)path
parameters:(NSDictionary *)parameters
responseModel:(Class)modelClass
success:(void (^)(NSDictionary *responseObject))success
failure:(void (^)(NSError* error, NSInteger statusCode))failure
{
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:parameters];
if (self.accessToken) {
// NSString *p = [NSString stringWithFormat:#"access_token=%#", self.accessToken];
NSString *percentageEscapedPath = [self.accessToken stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[params setObject:percentageEscapedPath forKey:kKeyAccessToken];
// [params setObject:self.appClientID forKey:kKeyClientID];
}
else
[params setObject:self.appClientID forKey:kKeyClientID];
[self.httpManager POST:path
parameters:params
#if (__IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_7_0)
success:^(AFHTTPRequestOperation *operation, id responseObject) {
#else
success:^(NSURLSessionDataTask *task, id responseObject) {
#endif
NSDictionary *responseDictionary = (NSDictionary *)responseObject;
success(responseDictionary);
}
#if (__IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_7_0)
failure:^(AFHTTPRequestOperation *operation, NSError *error) {
failure(error,[[operation response] statusCode]);
#else
failure:^(NSURLSessionDataTask *task, NSError *error) {
failure(error,((NSHTTPURLResponse*)[task response]).statusCode);
#endif
}];
}
I'm try to use AFNetworking to create a POST request. However I always return an error says:
Error Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: client error (422)" UserInfo=0x7ff1fa76a5c0 {com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x7ff1fa76ce40> { URL: https://isisfriends.zendesk.com/requests/mobile_api/create.json } { status code: 422, headers {
"Cache-Control" = "no-cache";
Connection = "keep-alive";
"Content-Length" = 33;
"Content-Type" = "application/json; charset=UTF-8";
Date = "Mon, 20 Oct 2014 14:56:54 GMT";
P3P = "CP=\"NOI DSP COR NID ADMa OPTa OUR NOR\"";
Server = nginx;
"Set-Cookie" = "_zendesk_shared_session=eyJpZCI6IjUxYjdmOGFjMzZjMzE1MjRjNDE0OTFiMjRmYmYzNjhhIiwibG9jYWxlX2lkIjoxfQ%3D%3D--229c90ddd7cf33dc5886aba445fd51cccaf69ea7; path=/; secure; HttpOnly, _zendesk_session=BAh7CkkiD3Nlc3Npb25faWQGOgZFVEkiJWVhZTRmZTQ5ZDQ1NmZjOTgzZDBlMzgyMWQ5YjMwMjNlBjsAVEkiDGFjY291bnQGOwBGaQMdNgdJIgpyb3V0ZQY7AEZpAuq9SSIOaXNfbW9iaWxlBjsAVFRJIhN3YXJkZW4ubWVzc2FnZQY7AFR7AA%3D%3D--c8bf5a2774eb5fdaa8ff7ec2da6adef3f76b15c3; path=/; secure; HttpOnly";
Status = "422 Unprocessable Entity";
Vary = Accept;
"X-Frame-Options" = SAMEORIGIN;
"X-Rack-Cache" = "invalidate, pass";
"X-Request-Id" = b71fc58dc1cf122d395b77968aff9014;
"X-Runtime" = "0.088859";
"X-UA-Compatible" = "IE=Edge,chrome=1";
"X-XSS-Protection" = "1; mode=block";
"X-Zendesk-Origin-Server" = "app13.pod2.sac1.zdsys.com";
"X-Zendesk-Request-Id" = 10c9143fd5ac87ab66d3;
} }, NSErrorFailingURLKey=https://isisfriends.zendesk.com/requests/mobile_api/create.json, com.alamofire.serialization.response.error.data=<7b226572 726f7222 3a22496e 76616c69 6420656d 61696c20 61646472 65737322 7d>, NSLocalizedDescription=Request failed: client error (422)}
Here is my code:
NSString * question = [_textFieldQuestion text];
NSString * detail = [_textFieldDetails text];
NSString * email = [_textFieldEmail text];
if(question.length > 0 && detail.length > 0 && email.length > 0)
{
NSString *url = #"https://isisfriends.zendesk.com/requests/mobile_api/create.json";
NSDictionary *parameters = #{#"subject":question, #"description":detail, #"email":email};
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
AFJSONRequestSerializer *reqSerializer = [AFJSONRequestSerializer serializer];
[reqSerializer setValue:#"application/x-www-form-urlencoded" forHTTPHeaderField:#"Content-Type"];
[reqSerializer setValue:#"1.0" forHTTPHeaderField:#"X-Zendesk-Mobile-API"];
manager.requestSerializer = reqSerializer;
manager.responseSerializer = [AFJSONResponseSerializer serializer];
NSLog(parameters.descriptionInStringsFileFormat);
[manager POST:url parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(#"===== JSON: ======= %#", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(#"============== Error: ============\n%#", [error description]);
}];
} else {
}
I'm petty sure the parameters I provided (subject, description, email)is corrent, becuase if I put the parameters directly in the url like below, it works fine.
https://isisfriends.zendesk.com/requests/mobile_api/create.json?subject=testing&email=testing#asd.com&description=testing
422 client error is for failed authentication. Check if you need any authentication or if you think You have permission, Look for the logged Failure error serialised in the console to check what server has to say about your call.
Use this simplified code:
NSString *myUrlString= YOUR LINK;
NSMutableDictionary* postRequestDictionary = [[NSMutableDictionary alloc] init];
postRequestDictionary[#"YOUR PARAMATER"]= YOUR PARAMETER VALUE;
// ... ADD ANY MORE PARAMETER IF YOU WANT HERE ...
NSLog(#"body = %#",postRequestDictionary);
AFHTTPRequestOperationManager *manager = [[AFHTTPRequestOperationManager alloc]init];
manager.responseSerializer = [AFJSONResponseSerializer serializer];
manager.requestSerializer = [AFJSONRequestSerializer serializer];
[manager.requestSerializer setValue:#"HEADER VALUE" forHTTPHeaderField:#"HEADER"];
// ... ADD ANYMORE HEADER IF YOU WANT ...
[manager POST:myUrlString parameters:postRequestDictionary success:^(AFHTTPRequestOperation *requestOperation,id JSON){
NSLog(#"%#",JSON);
} failure:^(AFHTTPRequestOperation *requestFailureOperation , NSError *error){
NSLog(#"%#",error);
NSData *errorData = error.userInfo[AFNetworkingOperationFailingURLResponseDataErrorKey];
NSDictionary *serializedData = [NSJSONSerialization JSONObjectWithData: errorData options:kNilOptions error:nil];
NSLog(#"Failure error serialised - %#",serializedData);
}];
Hope this helps. ๐๐
I'm having issue loggingout of my Localhost which is implemented by using Drupal 7
I've configured everything as mentioned by https://github.com/kylebrowning/drupal-ios-sdk
First of all, I wanna thank kylebrowning for spending his huge amount of time to create this awesome SDK.
The problem that i'm facing is that I can login just fine, but I failed logout.
I NSLog to see the error of the code.
Here is the error that shows on the out put tab.
I don't have enough reputation to post more than two links
here is what inside my http below, "192.168.1.24/drupal/rest/user/logout"
Domain=AFNetworkingErrorDomain Code=-1011 "Expected status code in (200-299), got 401" UserInfo=0x8c4d6c0 {NSLocalizedRecoverySuggestion=["CSRF validation failed"], AFNetworkingOperationFailingURLRequestErrorKey= { URL: ">" http:// }, NSErrorFailingURLKey=http:, NSLocalizedDescription=Expected status code in (200-299), got 401, AFNetworkingOperationFailingURLResponseErrorKey= { URL: http:// } { status code: 401, headers {
"Cache-Control" = "no-cache, must-revalidate, post-check=0, pre-check=0";
Connection = "Keep-Alive";
"Content-Length" = 26;
"Content-Type" = "application/json";
Date = "Thu, 27 Mar 2014 09:10:32 GMT";
Etag = "\"1395911432\"";
Expires = "Sun, 19 Nov 1978 05:00:00 GMT";
"Keep-Alive" = "timeout=5, max=98";
"Last-Modified" = "Thu, 27 Mar 2014 09:10:32 +0000";
Server = "Apache/2.2.25 (Unix) mod_ssl/2.2.25 OpenSSL/0.9.8y DAV/2 PHP/5.5.3";
"Set-Cookie" = "SESS0fd8593946486e6ecd06721db47d9fe9=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0; path=/; httponly";
Vary = Accept;
"X-Powered-By" = "PHP/5.5.3";
} }}
Here is my code
#import "AfterLoginViewController.h"
#import "DIOSUser.h"
#import "DIOSSession.h"
#import "DIOSSystem.h"
#interface AfterLoginViewController ()
#end
#implementation AfterLoginViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (IBAction)LogOut {
[DIOSUser
userLogoutWithSuccessBlock:^(AFHTTPRequestOperation *op, id response)
{
[self alertStatus:#"Logout Successful" :#"Sign Out Successful" :0];
NSLog(#"Logout Successful");
[self alertStatus:#"LogOut Successful" :#"LogOut is completed" :0];
[self performSegueWithIdentifier:#"BackToLogin" sender:self];
/* Handle successful operation here */
}
failure:^(AFHTTPRequestOperation *op, NSError *err)
{
[self alertStatus:#"LogOut Failed" :#"LogOut failed Please Try Again !!!" :0 ];
NSLog (#"Signout failed");
NSLog (#"%#", err);
}
];
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void) alertStatus:(NSString *)msg :(NSString *)title :(int) tag
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:title
message:msg
delegate:self
cancelButtonTitle:#"Ok"
otherButtonTitles:nil, nil];
alertView.tag = tag;
[alertView show];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#end
I would be very appreciated if someone can help me out with this issue.
Find in DIOSSystem class
this method
+ (void)systemConnectwithSuccess: (void (^)(AFHTTPRequestOperation *operation, id responseObject)) success
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error)) failure {
DIOSSession *session = [DIOSSession sharedSession];
[session getCSRFTokenWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {...}
and check if in getCSRFTokenWithSuccess the token is setted correctly like:
- (void)getCSRFTokenWithSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure {
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:#"%#/services/session/token", [[DIOSSession sharedSession] baseURL]]]];
[request setValue:[NSString stringWithFormat:#"text/plain"] forHTTPHeaderField:#"Accept"];
AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSString *aCsrfToken = [NSString stringWithUTF8String:[responseObject bytes]];
[[DIOSSession sharedSession] setCsrfToken:aCsrfToken];
if (success != nil) {
success(operation, responseObject);
}
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
[DIOSSession logRequestFailuretoConsole:operation withError:error];
if (failure != nil) {
failure(operation, error);
}
}];
operation.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:#"text/plain", #"application/json", nil];
operation.responseSerializer = [AFHTTPResponseSerializer serializer];
[self.operationQueue addOperation:operation];
}
Finally use this , works for me:
[DIOSUser
userMakeSureUserIsLoggedOutWithSucess:^(AFHTTPRequestOperation *op, id response) {
NSLog(#"LogOut success!");
}
failure:^(AFHTTPRequestOperation *op, NSError *err) {
NSLog(#"LogOut error: %#",err);
}
];