0

How do I save the credentials in SFOAuthCoordinator? The app is crashing if in

-[SFOAuthCoordinator authenticate]

method with message saying

'credentials.clientId cannot be nil or empty'

I am setting the credentials and saving it like this in the delegate method

- (void) oauthCoordinatorDidAuthenticate: (SFOAuthCoordinator *) coordinator    authInfo:(SFOAuthInfo *)info 
    {

    //  [SFAccountManager sharedInstance].coordinator = coordinator;
    //  [SFAccountManager sharedInstance].credentials = coordinator.credentials;
        [SFAuthenticationManager sharedManager].coordinator = coordinator;
        [[SFAuthenticationManager sharedManager] coordinator].credentials = coordinator.credentials;
        [[SFUserAccountManager sharedInstance] applyCredentials:self.coordinator.credentials];
        [[SFUserAccountManager sharedInstance] saveAccounts:nil];
    }

What am I missing here? Thanks! Note: I am updating the salesforcemobilesdk-ios to the latest version.

1

The app is crashing if in

The SDK may be throwing an exception that you are not handling, which terminates the app.

'credentials.clientId cannot be nil or empty'

You didn't specify an OAuth client ID for your app before trying to authenticate.

I am setting the credentials and saving it like this in the delegate method

This delegate method, oauthCoordinatorDidAuthenticate:authInfo:, is called AFTER authentication completes. Your sample code looks like it assigns a client ID and credentials, but these should be set before authenticating.

1
  • Let me try setting it before authentication and get back to you that. Thanks!
    – nOOb iOS
    Jan 20 '17 at 10:52
0

I had the exact same error occur when trying to create an example project based on a template. In the Salesforce docs is say to copy the template files into your Xcode project, but Xcode does not always set the target for all of the files added to the project.

Make sure that your bootconfig.json file has the target membership set to your application. You can verify this by selecting the bootconfig.json file in the project navigator. Once the file is selected, view the inspector panel on the right side of Xcode, and make sure that the checkbox for your target application is checked in the Target Membership box.

Target Membership box in the Xcode inspector

0

This might be late but I faced the same issue. Make sure that you are not missing the bootconfig.json file in your project directory. If the file is missing add the file toenter image description here your project and rebuild it. Hope this helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.