Cookie login failure (Cookie invalid or empty) in mobile SDK applications with SAML activated
How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!
While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.
Legacy Article
You are viewing an article from our legacy "FastTrack"
publication program, made available for informational purposes. Articles
in this program were published without a requirement for independent
editing or verification and are provided"as is" without
guarantee.
Before using any information from this article, independently verify its
suitability for your situation and project.
Resolution
- In this case the solution would be to use OAuth2 login method, redirecting to IdP (Identity provider) for login and, when successful, returning to the application having the role of SP (Service Provider).
-
The flow in the test-app application to make an OAuth2 redirect is the following:
- In LoginOAuth2RedirectInteractor.java#L32 use the Mobile SDK method signInWithRedirect from OAuth2SignIn.java#L45 to open a page Web View to log in.
- In the browser, the user is redirected to log in on the IdP (practically the normal login flow done in a browser after activating SAML).
- Once the login is successful, Authorization is requested so that the OAuth2 application can process this information.
- If we have the permission and authorize the OAuth2 application, it returns to verify the response in this LoginOAuth2ResumeRedirectInteractor.java#L28 method that calls the Mobile SDK resumeAuthorizationFlowWithIntent method in OAuth2SignIn.java#L25.
- The response is verified in TokenRequester.java#L88 and if everything has been successful, the user would be authenticated at this time.
- For all this to work, it will be necessary to follow these steps to configure your OAuth2 application:
- Go to Control Panel -> Settings -> OAuth2 Administration.
- With the plus button (+) Add OAuth2 application, specify a name and a callback URI we use in server_context.xml#L11 (you need to identify which one corresponds to yours in AndroidManifest.xml#L69). The rest is left as is. Click Save:
- We open the Scopes tab and in Portal Services we select all the available options (these are necessary to login, but others can be added if needed):

- We return to OAuth 2 Applications and on the right, in our application created in step 1, click on the 3-dot-icon context menu and select the "Permissions" option.
- By default, the Admin users have all the permissions, but for the other users to be able to authorize the application they need the 'Create token' and 'View' permissions:
- With this, we will have everything that is needed to make a successful login with OAuth2 redirect when SAML is activated in the portal.
Did this article resolve your issue ?