You need to sign in to do that
Don't have an account?
Usman Imtiaz
I've a Login with salesforce functionality enabled in my application. When I generate a login oauth url which consists of app secret and ket and after sending a get request using browser It redirects me to a previously used cache instance url.
It should redirect to https://login.salesforce.com/?ec=302&startURL=%2{someurl}
but instead it's redirecting to https://myinstance.salesforce.com/?ec=302&startURL=%2{someurl} although I'm logged out of salesforce and this url only accepts my login credentials which are linked with my instance where as login.salesforce.com accepts anyone's login credentials.
if I use incognito window it works fine and I've even tested the oauth url using postman the response is a html file which has javascript function which redirects to login.salesforce.com/?ec=302&startURL=%2{someurl}
Is there anyway I can solve this issue or force my oauth url to redirect to login.salesforce instead of cached url.
Salesforce oauth redirects to instance url for login
I've a Login with salesforce functionality enabled in my application. When I generate a login oauth url which consists of app secret and ket and after sending a get request using browser It redirects me to a previously used cache instance url.
It should redirect to https://login.salesforce.com/?ec=302&startURL=%2{someurl}
but instead it's redirecting to https://myinstance.salesforce.com/?ec=302&startURL=%2{someurl} although I'm logged out of salesforce and this url only accepts my login credentials which are linked with my instance where as login.salesforce.com accepts anyone's login credentials.
if I use incognito window it works fine and I've even tested the oauth url using postman the response is a html file which has javascript function which redirects to login.salesforce.com/?ec=302&startURL=%2{someurl}
Is there anyway I can solve this issue or force my oauth url to redirect to login.salesforce instead of cached url.
For authorization: https://login.salesforce.com/services/oauth2/authorize, the web client will send a request to this uri to get a request code, if no sf account is logged, it will direct the user to https://instance.salesforce.com instead of https://login.salesforce.com.
on different machines, I copied the same uri (https://login.salesforce.com/services/oauth2/authorize?****) into the browser, the redirected login uri is different, could be https://instance.salesforce.com or https://login.salesforce.com.
https://test.salesforce.com/services/oauth2/authorize?response_type=code&client_id=xxx&redirect_uri=xxx&prompt=select_account
For me, it won't redirect to instance URL with this parameter.
Thank you for the suggestion, sky Gong, do you know why prompt=select_account helps?
Much obliged to you for the idea, sky Gong, do you have at least some idea why prompt=select_account makes a difference?
May 15, 2020·Like0·Dislike1·Flag
I encountred the same problem the solution is in fact to append the prompt parameter to you request url as a parameter. In fact, as stated in the documentation (https://help.salesforce.com/s/articleView?id=sf.remoteaccess_oauth_web_server_flow.htm&type=5)
"
prompt : Specifies how the authorization server prompts the user for reauthentication and reapproval. Salesforce supports these values.
login —The authorization server must prompt the user for reauthentication, forcing the user to log in again.
"
So in my case I added the "...&prompt=login" to my authorization URL and it worked perfectly.
Have a good day.