0

enter image description hereI'm having trouble wrapping my head around how an external call to a Salesforce API resource works. I would like to call /services/data/v41.0/support/knowledgeArticlesfrom an already existing website from Javascript. I understand that I will need to authenticate somehow using oauth then once authenticated I need to pass my token along with my requests.

I have created a Connected App within my Salesforce Organization and made note of the Consumer Key and Consumer Secret, which as far as I understand I also have to pass.

What's the best way for me to build my request so that I can start hitting these endpoints? The documentation isn't very clear so I'm hoping for more than just some links to docs I've read already.

EDIT: As some comments have pointed out this may be a bit vague. My specific issue I'm running into is an inability to authenticate and receive my oauth token which I can that use to make API requests. The error I get is error=redirect_uri_mismatch&error_description=redirect_uri%20must%20match%20configuration. From some searching it seems like a configuration issue, probably in the Connected App I created, but I don't know what is incorrect.

The url I'm trying to authenticate with is also probably important, login.salesforce.com/services/oauth2/authorize with query parameters for client_id, response_type, and redirect_uri. I'm assuming client_id and Connected App Consumer Key are one in the same as I cannot find a client_id referenced anywhere in my Connected App.

closed as too broad by glls, Brian Mansfield, battery.cord, Oleksandr Berehovskyi, Himanshu Apr 27 '18 at 14:29

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    what part of the doc dont you seem to grasp? imo its pretty clear, however, if you pointed out in what step you are actually stuck, or are encountering errors while doing requests, it will be easier to provide pointers – glls Apr 26 '18 at 17:27
  • You will need to pass arguments as part of your request along with headers as required to the endpoint to retrieve the results. Refer to the section Input in Example on the documentation – Jayant Das Apr 26 '18 at 18:00
  • @glls I'm just guessing this, but he's probably trying to query knowledgeArticles. Which is a mess since you need to understand Knowldge Articles and Knowledge Articles Versions work and how to query them. Which work a bit different from standard/custom objects – Halfwarr Apr 26 '18 at 19:09
  • @glls @Halfwarr So I guess if we go step by step, I'm unable to authenticate as I get a error=redirect_uri_mismatch&error_description=redirect_uri%20must%20match%20configuration. I've used the workbench API explorer and know what url I need to hit to receive the JSON I want, I'm just struggling to implement the entire flow. – Karoly S Apr 26 '18 at 20:24
1

The error message seems pretty straightforward, your callback uri does not match the one you defined in your connected app. If you have follow up questions I strongly suggest you include the relevant part of your code as well as connected app config. Make sure you do it include tokens, secrets and any confidential information though.

This documentation Understanding the Web Server OAuth Authentication Flow might help you understand the concept, as it would seem like it is the first time you are doing this

  • Okay, so I seemed to have ironed out the issues that caused the error. A few follow up questions if you don't mind! Do I need a new connected app for each different callback_uri I have? I'm testing in localhost atm, and I have a dev and prod environment with different domains. Regarding authorization, am I correct in assuming that to use the API features my users have to have valid Salesforce credentials in this setup? Is there any way I can provide that access universally across my website without my users having to log in? – Karoly S Apr 26 '18 at 20:47
  • what service are you using to authenticate? if salesforce, you only need 1 SF connected app. you might want to open a new post with the specifics, as following up in the comments is not encouraged. – glls Apr 26 '18 at 20:51
  • Fair enough, I'll collect my follow up questions and tag you once I've posted – Karoly S Apr 26 '18 at 20:52
  • please dont tag ppl on the forum, we will see your post and be more than happy to help. Happy coding! – glls Apr 26 '18 at 20:53

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