function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Igor Androsov 22Igor Androsov 22 

How to pass custom parameters to Login page controller via OAuth services/oauth2/authorize

I am using Community as Identity for my Heroku app via OAuth Web Server flow. Standard login works ok.
Now I need to pass a custom parameter to my controller during this Login flow and do not see a way to do this. I try to use URL params but that get removed during redirect of OAuth dance/flow.

My community page is passing parameter if I hit that URL directly. But if I use community URL it does not get this parameter. That seems to be restricted set what can be passed to OAuth as documented here: https://developer.salesforce.com/page/Digging_Deeper_into_OAuth_2.0_on_Force.com

But I want to know if it is possible, anyone has done it to pass any custom parameter from initial request to Controller?
In My example, I need to add parameter <URL>?poi=999 to my OAuth request and get this value in my Login controller.
My current URL format that does not work: https://<COMMUNITY HOST>/services/oauth2/authorize?response_type=code&poi=999&client_id=<MY LONG CLIENT ID>&redirect_uri=http://localhost:8080/authorized&prompt=login consent&display=page
 
Andrea Lomazzi 10Andrea Lomazzi 10
Hi Igor,
have you found a solution? I'm in the same situation now :). I need to pass a value to the url, but seems doesn't mantain the value, instead i have only startURL parameter
Leanbridge TechnologiesLeanbridge Technologies
I configured my setup as stated above in my Edit/Update. It works. 1) I configured a CustomAuthenticationEntryPoint 2) Did a @Override protected String determineUrlToUseForThisRequest() to build my login string with a query parameter passed in from client's request. 3) LoginController does this
@GetMapping("/login") public ModelAndView showCustomLoginForm(@Valid @RequestParam(value = "realm_name", required=false) final String realmName) { CustomLoginForm form = new CustomLoginForm(realmName); return new ModelAndView(CUSTOM_LOGIN_FORM_VIEW, CUSTOM_LOGIN_FORM_MODEL, form); }