![]() |
|
IW OAuth2 Question - Printable Version +- Atozed Forums (https://www.atozed.com/forums) +-- Forum: Atozed Software (https://www.atozed.com/forums/forum-1.html) +--- Forum: IntraWeb (https://www.atozed.com/forums/forum-3.html) +---- Forum: English (https://www.atozed.com/forums/forum-16.html) +----- Forum: IntraWeb General Discussion (https://www.atozed.com/forums/forum-4.html) +----- Thread: IW OAuth2 Question (/thread-3201.html) |
IW OAuth2 Question - ioan - 05-01-2023 I am currently trying to integrate the new OAuth2 protocol into my project, but I am facing difficulties in finding the correct approach. Typically, when a user navigates to our web address, I check in the "IWServerControllerBaseGetMainForm" method if they have a cookie set, indicating they are already logged in and have chosen to stay logged in. There are two possible scenarios:
My question is, how can I check in the server controller whether the user is already logged in using their Google credentials so that I can set the "vMainForm" accordingly in "IWServerControllerBaseGetMainForm"? Thanks! RE: IW OAuth2 Question - Alexandre Machado - 05-04-2023 Hi Ioan, This was something that I considered while I was developing it. The general way to handle this is to save a second cookie in the browser and save the user data on your server (it could be even a local file but ideally in your database). This cookie has a much longer expiration date, let's say a few days. If the cookie exists when you receive the first request, you should use it to retrieve the user information on the Database and bypass the login altogether. I'll see if I can put together some code to show how it is done. RE: IW OAuth2 Question - Alexandre Machado - 05-09-2023 For the sake of keeping this conversation public, so other people can benefit from it, I'll post here some information that Ioan and I exchanged via e-mail: First, Ioan pointed me out this SO post where an user has a similar problem: https://stackoverflow.com/questions/359472/how-can-i-verify-a-google-authentication-api-access-token Then, this was basically my response: Quote:The question that you pointed out has a slightly different nature. In that question case, they are interested in finding out if the token abc123 was actually issued granting access to joe@doe.com, because in that example the user is building an API which has no control over the authorization code request. The token is received in every request and needs to be checked. Having said that, in the next release we are extending the OAuth support even further, including Facebook API and other features that will allow to handle case (2) above easily. We are also re-writing the demo application to be a comprehensive one, showing how to deal with this issue. Cheers RE: IW OAuth2 Question - joelcc - 05-10-2023 I believe this will work really well. RE: IW OAuth2 Question - ioan - 05-24-2023 Hi Alexandre, I have implemented the new OAuth features in my application, and overall, everything is functioning well. However, I am encountering some issues still with the main form. Let's consider the following scenario: 1. When a user is not logged in, they are presented with a login/password form, which also offers the option to log in with Google. At this point, the main form has already been assigned (login form), and the user session has been created. 2. If the user chooses to log in with Google, the application goes through the entire login process, including saving the cookie and storing the relevant information in the database. 3. Here lies the problem: even after successfully logging in with Google, the login form continues to be displayed to the user. Since the IWServerControllerBaseGetMainForm event no longer fires (and no event fires in the login form, except the IWAppFormRender), I am unable to proceed to the next form, the user menu. Now, if the user closes the browser and starts a new session, I can check whether the user has the cookie with the token hash and set the main form accordingly. However, I am specifically referring to the situation immediately after the user clicks "log me in with Google." I am unsure how to advance to the next form, which is the user menu. RE: IW OAuth2 Question - Alexandre Machado - 05-30-2023 I'll try to change the demo application accordingly and get back to you on this, Ioan. Hold on |