Parse error codes 209 and -34018 - ios

I have spent several hours learning user management on Parse, thinking it would be easy considering it's been an established service for so long.
There is poor documentation around 'automatic user' and sessions.
I am trying to build an App that allows the user to exist anonymously (using [PFUser enableAutomaticUser]), before they decide to sign up.
Registration Steps:
Gather user details from the UI
Log out current automatic user and wait for success
Upon success create a user object using [PFUser user] and assign values
Call signUpInBackgroundWithBlock on the new user instance
I sometimes get the following errors (yes, only sometimes), when doing the above.
[Error]: PFKeychainStore failed to get object for key 'currentUser', with error: -34018
[Error]: invalid session token (Code: 209, Version: 1.7.0)
I also end up with a dirty database, because I don't know how to delete the automatic user that was previously created. I tried keeping the object id of the old user around and using deleteEventually but that didn't work?
Any advice on how you would go about achieving this would be great.

Take a look at this issue with parse on iOS: https://github.com/ParsePlatform/Parse-SDK-iOS-OSX/issues/437.
I believe this was an issue in iOS and is now fixed

Actually, this is a bug of keychain, you can search it at github.
Github 34018 issues
A few months ago, some apple's staff came our company to give us a course, after course,we asked this question, they also did't give us a solution

I've solved this problem by using the following:
PFUser *user = [PFUser currentUser];
[user refreshInBackgroundWithBlock:^(PFObject *object, NSError *error) {
if (!error) {
NSLog(#"Succesfully refreshed the current user.");
} else {
NSLog(#"Failed to refresh the current user with error %#", error);
}
}];
It seems that [PFUser currentUser] returns an invalid session token which is causing the 209 and -34018 errors. This is only an issue when the current user is an anonymous user.

Related

MSGraphSDK user details API callback not responding back when user password changed in iOS

I tried to get the user details using MSGraph SDK in iOS using below API method. Iam successfully received the user details all the time. But when user charged their password or update their credentials, i received the oauthConnection Error: only in log. And i didn't receive any call back in the below API. Why it is not responding back when any kind of error occurred? Please help me. Thanks in advance.
[MSGraphClient setAuthenticationProvider:self.authProvider.authProvider];
self.graphClient = [MSGraphClient client];
[[[self.graphClient me]request]getWithCompletion:^(MSGraphUser *response, NSError *error) {
if(!error){
// Im able to get back here
}
else{
//Im not received any call back here when user changed their password or any error occurred.
[self.authProvider disconnect];
}
}];`
I am kinda new to MS Graph, so I might be missing something, but your graphClient declaration seems a little bit poor to me.
Try to download this sample: https://github.com/Azure-Samples/active-directory-dotnetcore-daemon-v2
And check it's declaration of graphClient.
You might be missing the part which refreshes the token?

AWS Cognito Update user login issue in iOS

I am working on AWS Cognito login. It works fine in all cases such as SignUp, signIn, Forgot password etc. But it edit profile case, I am facing some technical problems. I edited my mobile number successfully.
In one of the case I provide wrong number and it throws an error like this,
[AWSJSONResponseSerializer responseObjectForResponse:originalRequest:currentRequest:data:error:] | Response body: {"__type":"InvalidParameterException","message":"Invalid phone number format.”}
I am using this set of code to update my profile,
[[user updateAttributes:#[attributes]] continueWithSuccessBlock:^id _Nullable(AWSTask<AWSCognitoIdentityUserUpdateAttributesResponse *> * _Nonnull task) {
//success
return nil;
}];
It provides only success responses. Failure responses are not coming inside this block. Can anyone help me how to get failure messages in this. I tried so many ways but still troubling to get proper solution. Any help will be appreciated. Thanks.

Where can I view my PFUser objects in the Parse Data Browser?

I'm getting to know Parse and am already having a tough problem.
I'm working with the User Login flow. I need to be able to delete the User object I've just created. Problem is, on the Dashboard, I only have the Installation data table.
I realized I wasn't explicitly saving this user object, although locally (on iOS) I could log in with the currentUser object credentials. So I thought I'd remove the install from the simulator and try again (hey, since my data wasn't on the dashboard.)
Now I tried re-installing the app, using the same username/pass, and Parse SDK is telling me these are already taken!
So the question is, where is this User, and how do I completely remove the data so I can start over again?
2015-10-15 16:37:29.999 ParseApp[21428:2003831] [Error]: username myUserName already taken (Code: 202, Version: 1.8.5)
This doesn't solve the problem, but is kind of like a workaround for testing purposes. I made a method:
- (IBAction)pressedDeleteSelf:(id)sender
{
[[PFUser currentUser] deleteInBackgroundWithBlock:^(BOOL succeeded, NSError * _Nullable error) {
if (succeeded) {
[PFUser logOut];
[self performSegueWithIdentifier:#"unwindSignedOut" sender:self];
}
}];
}
Which then allows me to re-create a user with the same credentials. I still have no idea why the PFUser table does not show up in the Dashboard.
Oh myyy... how silly do I feel. With all these different tutorials I've been running, apparently I had been doing all this stuff using the wrong AppID and Client Key. A rookie mistake, but hopefully someone else doesn't have to trip on this.
To be clear, solution is to make sure your App ID and Client key in the Parse dashboard match what you call in code:
// Initialize Parse.
[Parse setApplicationId:PARSE_APP_ID
clientKey:PARSE_CLIENT_KEY];
Embarrassed...

Apigee user authentication, access_token, and cache login session in iOS

I'm new to Apigee and can't seem to wrap my head around it. I am familiar with implementing an iOS app that talks to a database via a webservice call. The call would involve passing back and forth JSON or variables though POST, GET, etc.
The user flow I envision is a lot like Facebook long term token storage. Here are the steps:
Type username and password to login.
The app will remember the access_token in the keychain.
The access_token will be used with any future requests such as updating profile. This way the user doesn't have re-login every time he/she is using the app.
Log out will clear all the token.
If the token is invalid or expired, the app will take the user back to login.
I've taken multiple routes and ended up getting stuck on all of them when it comes to Apigee.
ROUTE 1
I made a call to logInUser and receive access_token in return.
[self.apigeeDataClient logInUser:username password:password];
All this is good until I want to update user's email address using the code below.
NSMutableDictionary *requestDict = [NSMutableDictionary dictionary];
[requestDict setObject:email forKey:kDataEmail];
NSString *url = [NSString stringWithFormat:#"%#/%#/%#/users/%#?access_token=%#", BASE_URL, UG_ORG_NAME, APP_NAME, [userData objectForKey:kDataUUID], self.accessToken];
NSString *op = #"PUT";
NSError *error;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:[NSDictionary dictionaryWithDictionary:requestDict]
options:0
error:&error];
[self.apigeeDataClient apiRequest:url operation:op data:[NSString stringWithUTF8String:[jsonData bytes]]];
It seems that every other time it's giving me "No content to map to Object due to end of input" error. I checked out this thread but have no luck. I made sure the JSON object is not null. I tried changing the operation from PUT to POST and GET. None of which update the email address in the database.
ROUTE 2
Instead of using apiRequest, I switched to updateEntity.
NSMutableDictionary *requestDict = [NSMutableDictionary dictionary];
[requestDict setObject:email forKey:kDataEmail];
[requestDict setObject:kDataUsers forKey:kDataType];
[requestDict setObject:self.accessToken forKey:kDataAccessToken];
NSString *entityID = [userData objectForKey:kDataUUID];
[self.apigeeDataClient updateEntity:entityID entity:requestDict];
It looks promising except I started getting "Subject does not have permission" like the issue described in this thread. I tried calling assignPermissions like mentioned in Apigee document but that didn't solve the problem. I even provide access_token with the call, even though I shouldn't have to.
In the attempt to avoid calling login also tried calling storeOAuth2TokensInKeychain and retrieveStoredOAuth2TokensFromKeychain mentioned here. That didn't work either.
The only thing way to resolve this error is by calling logInUser before making a call to updateEntity. This means the user will have to login every time he/she wants to use the app. I know I can store username/password in the keychain. But before I do that I'm wondering if there's better solution out there.
I know it's a long post. So thank you for reading this far. Any pointers are greatly appreciated.

AWS DynamoDB iOS SDK silently failing but always returning success status

I've created an iOS application following AWS Mobile SDK examples using AWSiOSSDKv2.
I've successfully been able to connect with an unauthorized Cognito account to DynamoDB and write to the table. I log into AWS, check the table and see my records are there.
AWSDynamoDBObjectMapper *dynamoDBObjectMapper = [AWSDynamoDBObjectMapper defaultDynamoDBObjectMapper];
[[dynamoDBObjectMapper save:tableRow] continueWithSuccessBlock:^id(BFTask *task) {
if (!task.error) {
NSLog(#"Successfully inserted the data into the table.");
} else {
NSLog(#"Failed to insert the data into the table.");
}
return nil;
}];
However, now I want to test what will happen in a failure. I deliberately try to cause an error by changing the dynamoDBTableName to something that does not exist. Unfortunately, my code always returns success even tho it was not.
I found in another thread someone recommending putting logging to verbose which I did.
[AWSLogger defaultLogger].logLevel = AWSLogLevelVerbose;
And in the console, I do see that AWSLogger displays an error:
[{"__type":"com.amazon.coral.service#AccessDeniedException","Message":"User:
arn:aws:sts::xxxxxx:assumed-role/Cognito_xxxxxxxxUnauth_DefaultRole/iOS-Provider
is not authorized to perform: dynamodb:PutItem on resource:
arn:aws:dynamodb:us-east-1:xxxxxxxxxxxxx:table/xxxxxxxx"}]
However, In my code above, it always writes "Successfully inserted the data into the table.".
I've even tried modifying AWS Mobile Examples and can reproduce the same bug. I've also tried installing the POD and manually adding the AWSiOSSDKv2 framework to my project, neither fix the issue.
Has anyone run into this issue and does anyone know how to resolve? I'm trying to create an unauthorized user who only has write access to the dynamodb table.
Thanks
This is a known issue of the SDK, and the fix is on its way.
In the meanwhile, if you are using CocoaPods, adding the following lines to AWSDynamoDBObjectMapper.m L154 should fix it:
if (task.error) {
return task;
}

Resources