Explore Courses Blog Tutorials Interview Questions
0 votes
in Salesforce by (11.9k points)

I am using Salesforce API and I want to log in automatically(hard code user name and password). I am using REST API and here is the login code which shows login form:

- (void)login {

                SFOAuthCredentials *credentials = [[[SFOAuthCredentials alloc] initWithIdentifier:remoteAccessConsumerKey] autorelease];

                credentials.protocol = @"https";

                credentials.domain = OAuthLoginDomain;

                credentials.redirectUri = OAuthRedirectURI;

                self.coordinator = [[[SFOAuthCoordinator alloc] initWithCredentials:credentials] autorelease];

                self.coordinator.delegate = self;


                // remove this line if we want to cache the key, and use refresh flow

                //effectively, we are saying, purge the old login and re-authenticate each time

                [self.coordinator revokeAuthentication];

                //now let's authenticate

                [self.coordinator authenticate];


What I want, to automatically login (not ask username or password) so where I insert user name and password?

1 Answer

0 votes
by (32.1k points)
edited by

The REST API generally uses an OAuth token which prevents the user from having to access their username and password into a third-party system like yours. It starts when they enter the login IDs once and then the system refreshes the token in order to stay logged in (this is an oversimplified explanation). Either use OAuth which is the correct way with mobile and the REST API or use the session ID from an old-style SOAP login request.

Want to learn Salesforce in depth? Go through the Salesforce Training provided by Intellipaat!

Related questions

+1 vote
1 answer
0 votes
1 answer
+1 vote
1 answer

Browse Categories