0 votes
1 view
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;

                NSLog(@"%@",self.coordinator);

                // 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 (30.1k points)
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.

Related questions

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...