I am exploring some REST APIs. Various APIs requests are initiated from a visualforce page and are processed by apex in controller. At some point we are thinking to provide a 'Advanced Options' link in visualforce page. This link should redirect user to web application login without entering his credentials (credentials are stored in Salesforce). I tried processing this request by apex and failed to do so.I followed below steps:
- Clicking 'Advanced Options' called login method in apex.
- Successfully Called REST based login api method
- Created a Pagereference object for post-login landing page.
- Collected cookies from response and put those all to Pagereference object. Pagereference was sent back to browser to load.