2

I have exposed an apex class as a rest service. I want my community users to be able to use the rest service to insert records in the system. I have set up a connected app to enable access using Oauth.

I followed the steps mentioned here. The guide mentions the request format to be of the form

https://acme.force.com/customers/services/oauth2/authorize?​response_type=token&client_id=your_app_id&redirect_uri=your_redirect_uri

My resultant url was of form :

https://xxxxx-xxxxxxxx.xx6.force.com/xxxxcommunity/services/oauth2/authorize?​response_type=token&client_id=my_consumer_key&redirect_uri=connected_app_callback_url

This resulted in error=unsupported_response_type&error_description=response%20type%20not%20supported

I then tried using the AxiomSSO heroku app. This generated a URL of the form :

https://xxxxxx.force.com/omplcommunity/services/oauth2/authorize?response_type=code&display=popup&client_id=my_consumer_key&redirect_uri=connected_app_callback_url

On requesting authorization code, it opens up a page titled 'Login Template' which then changes to 'Login but is blank. I was expecting my community's login page but the page is entirely blank. I would deeply appreciate any help regarding this.

Additional Info if it matters :

  1. At profile level, I've given the System Permission - 'Api Enabled', Apex class has been appropriately enabled along with the connected app.

  2. The custom app has 'Require Secret for Web Server Flow' checked

  3. I am able to use the web service using users with standard salesforce license.

1
  • Are you deliberately putting "response_type=token" because this is different flow for desktop or mobile which does not require client secret? If it's web app then response type should be 'code'
    – Ayub
    Commented Apr 8, 2020 at 15:50

1 Answer 1

2

When you copy and paste URLs or URL fragments from help.salesforce.com, you might copy an invisible control character that represents a continuation of two lines. On Windows, this control character is a left-to-right mark. In UTF-8 this control character is E2 80 8E or %E2%80%8B when URL-encoded. When you paste a URL into some tool and/or browser, depending on the tool and/or browser configuration, you may not see the character because it's, well, invisible.

URL with the control character:

.../services/oauth2/authorize?%E2%80%8Bresponse_type=token&client_id=my_consumer_key&redirect_uri=connected_app_callback_url

Running this URL against any Saleforce token endpoint will correctly produce error=unsupported_response_type

Correct URL without the control character:

.../services/oauth2/authorize?response_type=token&client_id=my_consumer_key&redirect_uri=connected_app_callback_url

Bonus: don't use the implicit grant type (response_type=token), it's no longer considered secure

2
  • I tried copying pasting the correct URL you posted in your answer. Ensured there was nothing additional and it still takes me to a blank page titled "Login". I still do not see my community's login page.
    – N_H1922
    Commented Apr 9, 2020 at 4:31
  • 1
    @N_H1922 Blank login page is a different issue, likely related to the way you configured community login options..but could be something else too. This flow works for us with an out of the box community. You might want to create a new question instead of combining multiple questions into one. That way, it helps the people answering your question and also others hunting for at least one of your questions. Thanks!
    – identigral
    Commented Apr 9, 2020 at 4:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .