1

newb here.

I am trying to log in to a Salesforce account using AngularJS ForceNG and pull the data out of an object so I can post it on an Ionic page. I want to hard code the login and password, access the Salesforce REST API, query it, and run that information on a page. The trouble that I am having is with gaining access to the Salesforce account.

I know that I need to use OAuth in order to do this. I have not found any examples on the internet regarding how to access Salesforce directly using OAuth with hardcoding the login and password. All examples I find are very long pieces of code with many different update/create/etc. options.

I just want to log in, query the data, and post it onto a web page. It seems like it should be a simple thing to do but I am having immense trouble with it.

Does anybody have any tips on how to hard code the login and pull the data in OAuth?

  • If you are thinking of hard-coding the username and password in client code then you are allowing any of your users with hacking skills to get hold of those and abuse them... The conventional (secure) approach is to use e.g. the user agent flow (see Digging Deeper into OAuth 2.0 on Force.com). – Keith C Mar 28 '16 at 21:07
1

You can follow the Username-Password flow. That way you don't have to redirect a user to a login page.

The username-password authentication flow can be used to authenticate when the consumer already has the user’s credentials. In this flow, the user’s credentials are used by the application to request an access token as shown in the following steps.

Complete docs are here

  • Do you know if there are any code examples of username-password authentication flow? I have looked around and haven't come up with much. – RPONYJ Mar 28 '16 at 20:51
  • There is one in the doc I linked to. :) – Sebastian Kessel Mar 28 '16 at 20:52

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.