What happens if apex token is not valid?
It is invoked by APEX to find out if a login is necessary. For our requirement this is perfect, because we can instantiate a session if the given token is valid, and get APEX to show the login-screen if token is invalid or not present. Let’s walk through the function and explain what we do: Line 4 grabs the URL.
How is page Sentry used to authenticate apex?
The Page Sentry Function is used to determine whether the current session is valid, or not. It is invoked by APEX to find out if a login is necessary. For our requirement this is perfect, because we can instantiate a session if the given token is valid, and get APEX to show the login-screen if token is invalid or not present.
How to create a new session in apex?
Line 41 sets the used timestamp in the token table. Lines 47-60 try to reuse an existing session-id. If no session exists, or it isn’t valid anymore, a new one will be created. Line 63 tells APEX to define a session for given username. That was easy, right?
Which is the second possible solution for token based authentication?
The second possible solution for token based authentication is by using the Invalid Session Function. It looks very similar to our first approach, the big difference is that his procedure will be invoked by APEX only if there is no or an invalid session and that it will create a new session with every call.
How to access Apex Rest API using customer portal users?
To do this you create a Force.com site and then expose the classes for the API as available to the guest user. OAuth username/password flow also required “Security token”. User need to add “security token” to password. But for customer portal users we cannot get “Security token”.
How to get access token using customer portal?
We are planning to use customer portal Url, user details to get access token and access those API’s. In order to get access token we need “security token” of that user but for customer portal users we cannot get “security token”. So that now we are unable to access those API’s using customer portal user.
How to access Apex Rest API’s from external system?
We have created bunch of APEX REST API’s (for data integration like creating Cases, adding attachments etc) in one of my clients org. And now we need to access these API’s from external system (Java). We are planning to use customer portal Url, user details to get access token and access those API’s.