0

I'm building a wordpress-site, which needs access to my salesforce-data. I'm using the REST API, and have set up the connected app with Oauth. When Once the user is authenticated as a community-user and have fetched the access_token, I perform the ajax like below.

    $.ajax({
  url: "https://<portalpath>/services/data/v42.0/sobjects/Opportunity/",
  type: "GET",
  dataType: "json",
  headers: {
    'Authorization':'Bearer '+access_token,
    'Content-Type':'application/json'
  },
  //data: info,
  success: function(result){
    console.log(result);
  },
  error: function(xhr){
    console.log(xhr);
  }
});

But I get a 404-error (The requested resource does not exist). I can't understand why, I've seen many examples using this endpoint, I've also used it in PostMan.

The community-user profile has this setting: "Access any Salesforce.com API.". The connected app has this community-user-profile in the permissions list, and I've also added all OAuth Scopes. Is there any other setting I'm missing here?

  • 2
    Is this user of a profile and license type that has the right to access Opportunities? – David Reed Apr 17 '18 at 15:56
  • @DavidReed I don't think so. I could find find this setting. Under Setup->user->permission set->the set with 'customer community login'-license, I can't find any opportunity-setting. But this will also make the user allowed to see and edit existing opportunities in their salesforce user, or just access these in the api? – Marius W Apr 18 '18 at 6:54
2

The Customer Community and Customer Community Plus licenses, and their Login-based counterparts, are not permitted to access the Opportunity object at the license level. That's why you have no settings for Opportunity in their profile: they have no access to the object at all, full stop, and using the API does not allow an end run around this restriction.

  • Ok, I see. But I have a requirement to create an opportunity whenever a community user are on the website and clicks "buy". Do you have any suggestion on how to do this? Can't do this with the salesforce public apex rest api, because it will not be safe for the user without any authentication on serverside. Any tips? @DavidReed – Marius W Apr 20 '18 at 5:01
  • Maintain a durable Oauth connection using an integration user on a license that has the right to create Opportunities. – David Reed Apr 20 '18 at 10:48
  • Thanks, I have been trying to do this earlier, but could not figure out how to do that. Do you have any pointers on how to do this? @DavidReed – Marius W Apr 24 '18 at 14:24
  • I'm afraid I've never implemented this type of login flow from a separate web application, so I don't have a great example for you. You'll find lots of material if you search for "Oauth" on SFSE, although you have some sorting through to do! – David Reed Apr 24 '18 at 14:26

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.