# Login with Google

{% tabs %}
{% tab title="Without JFW" %}

* **A user clicks on the "Login with Google" button.**
* **Redirect User to Google Login Page:**
  * The JFW redirects the user to the Google OAuth 2.0 login page.
* **The user enters their Google credentials:**
  * The user inputs their Google email and password.
* **The user grants permissions:**
  * After authentication, Google asks the user to grant permission to access their information through the application.
* **Retrieve Authorization Code:**
  * Upon consent, Google redirects the user to the application with an authorization code.
* **Exchange Authorization Code for Access Token:**
  * The application sends the authorization code to Google's token endpoint to exchange it for an access token.
* **Retrieve the User Information:**
  * The application requests the user's profile information from Google using the access token.
* **The user logged in:**
  * The application creates a new user session or updates an existing session based on the information retrieved from Google.
* **Display User Information:**
  * After a successful login, the application displays the user's profile information or proceeds with the user-specific workflow.
    {% endtab %}

{% tab title="With JFW" %}

* **A user clicks on the "Login with Google" button.**
* **Redirect User to Google Login Page:**
  * The JFW redirects the user to the Google OAuth 2.0 login page.
* **The user enters their Google credentials:**
  * The user inputs their Google email and password.
* **The user grants permissions:**
  * After authentication, Google asks the user to grant permission to the application to access their information.
* **Retrieve the user Information:**
  * Google redirects the user back to the JFW API with an authorization code.
  * JFW sends the authorization code to Google's token endpoint to exchange it for an access token.
  * Using the access token, JFW requests the user's profile information from Google.
  * After retrieving the user's information, JFW creates (if the Google account doesn't exist) or gets the user (which the Google account is linked to).
* **The user logged in:**
  * JFW redirects to the application callback API with state information:
    * Where to redirect after authentication.
    * The username of the user.
    * The AuthKey of the user.
* **Display User Information:**
  * After successful login, the API will handle and then display the user's profile information or proceed with the user-specific workflow.
    {% endtab %}
    {% endtabs %}
