---
title: "Easily Implement Google Authentication in the Blazor WebAssembly App"
published_at: "2024-06-04T10:20:15+00:00"
modified_at: "2026-01-21T12:22:22+00:00"
url: "https://www.syncfusion.com/blogs/post/google-authentication-blazor-wasm-app"
excerpt: "This blog explains how to integrate Google authentication into your Blazor WebAssembly app for enhanced security and user experience."
taxonomy_category:
  - "Blazor"
  - "Development"
  - "Security"
  - "UI"
  - "Web"
taxonomy_post_tag:
  - "Authentication"
  - "Blazor"
  - "productivity"
  - "Web Development"
  - "WebAssembly"
---

# Easily Implement Google Authentication in the Blazor WebAssembly App

[Alan Sangeeth](https://www.syncfusion.com/blogs/author/alans)

![Easily Implement Google Authentication in the Blazor WebAssembly App](https://www.syncfusion.com/blogs/wp-content/uploads/2024/06/Easily-Implement-Google-Authentication-in-the-Blazor-WebAssembly-App.png)


**TL;DR:** Easily implement Google authentication in your Blazor WebAssembly app for enhanced security. Generate Google credentials, add them to your app, install the Google authentication library, and configure your app. We’ll also customize the login page to match your app’s design. Refer to the GitHub demo for detailed steps and code examples.

In the dynamic world of web development, security remains a paramount concern. Ensuring that users securely access the right resources and data is non-negotiable. Building upon our previous exploration of authentication with Azure Active Directory (AAD) in a [Blazor WebAssembly app](https://www.syncfusion.com/blogs/post/how-to-authenticate-a-blazor-webassembly-hosted-app-with-azure-active-directory.aspx)
, we now delve into another crucial aspect: enabling authentication using external providers, explicitly focusing on Google authentication.

Google authentication offers a seamless and widely-used method for users to securely log in to apps using their Google accounts. Leveraging Google’s authentication services enhances your app’s security and provides users with a familiar and convenient authentication experience.

So, let’s get started!

## Implementing Google authentication in the Blazor WebAssembly app

Follow these steps to implement Google authentication in Blazor WebAssembly apps:

### Step 1: Generate Google client ID and client secret

Begin by generating your [Google client ID and client secret](https://learn.microsoft.com/en-us/aspnet/core/security/authentication/social/google-logins?view=aspnetcore-7.0#create-the-google-oauth-20-client-id-and-secret)
. This involves navigating through Google’s developer console and creating credentials specific to your application.

### Step 2: Integrate Google credentials

Open the **appsettings.json** file of your server app and modify it by adding the Google credentials.

```
"Authentication": {
   "Google": {
     "ClientId": "xxx-xxxx.apps.googleusercontent.com",
     "ClientSecret": "xxxx-xxxxxxxxnu"
   }
 },
```

Ensure the client ID and secret match those generated in the previous step.

### Step 3: Install the Google authentication library

Next, incorporate the [Google authentication library](https://www.nuget.org/packages/Microsoft.AspNetCore.Authentication.Google)
 into your server app using the following command in the **Package Manager Console** of ** Visual Studio**.

```
Install-Package Microsoft.AspNetCore.Authentication.Google -Version 8.0.1
```

This command installs the necessary dependencies to enable Google authentication within your app.

### Step 4: Configure Google authentication

Once the package installation is finished, modify the **Program.cs** file to call the ** AddGoogle** method with ** ClientId** and ** ClientSecret** options.

```
builder. Services
    .AddAuthentication()
    .AddIdentityServerJwt().AddGoogle(o =>
    {
      o.ClientId = builder.Configuration.GetValue<string>("Authentication:Google:ClientId");
      o.ClientSecret = builder.Configuration.GetValue<string>("Authentication:Google:ClientSecret");
    });
```

After everything is set up, run your application. The Google option is available on the Login or Register page. This Google button is rendered by default from the [Google authentication library](https://www.nuget.org/packages/Microsoft.AspNetCore.Authentication.Google)
, as we have used the **RemoteAuthenticatorView** component of [Microsoft.AspNetCore.Components.WebAssembly.Authentication](https://www.nuget.org/packages/Microsoft.AspNetCore.Components.WebAssembly.Authentication/)
 package on our authentication page.

Refer to the following image.


Implementing Google authentication in the Blazor WebAssembly app

Now, users can effortlessly authenticate using their Google accounts.

## Customizing the login page in the Blazor WebAssembly app

By default, Blazor WebAssembly authentication provides pre-defined login views using the [RemoteAuthenticatorView](https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.components.webassembly.authentication.remoteauthenticatorview?view=aspnetcore-7.0)
 component, which is visible on the client app page, [Client/Pages/Authentication.razor](https://github.com/SyncfusionExamples/authentication-and-authorization-in-blazor-web-assembly/blob/master/BlazorWASMAuthentication/Client/Pages/Authentication.razor#L5)
. However, there are situations where aligning the login page with your application’s unique design and branding becomes imperative.

Let’s see how to customize the login page to meet your specific requirements.

### Step 1: Scaffold identity items

1. Navigate to the **Areas** folder in your server app and right-click on it to open the contextual menu.
2. Select **Add** < ** New Scaffolded Item**…”[https://www.syncfusion.com/blogs/wp-content/uploads/2024/06/Add-New-Scaffold.png](https://www.syncfusion.com/blogs/wp-content/uploads/2024/06/Add-New-Scaffold.png)
3. Choose **Identity** and proceed by clicking ** Add**.
4. Select your identity data context class and specify the items you wish to scaffold. Then, choose the **Account/Login** option to customize the login page.[https://www.syncfusion.com/blogs/wp-content/uploads/2024/06/Scaffold-Login-Identity.png](https://www.syncfusion.com/blogs/wp-content/uploads/2024/06/Scaffold-Login-Identity.png)

### Step 2: Customize the login page

Once the Identity items are scaffolded, the login page will be imported into your application under **Areas/Identity/Pages/Account/Login.cshtml**. You now have complete control over customizing it according to your preferences.

Here, I have done a very simple customization. I have moved the position of the external login (Google) button to the bottom.[https://www.syncfusion.com/blogs/wp-content/uploads/2024/06/Login-Page-Customization.gif](https://www.syncfusion.com/blogs/wp-content/uploads/2024/06/Login-Page-Customization.gif)

After implementing the necessary modifications, run your app to view the customized login page


Customizing the login page in the Blazor WebAssembly app with Google substantiation

## GitHub reference

For more details, refer to the [implementing Google authentication in Blazor WebAssembly app GitHub demo](https://github.com/SyncfusionExamples/authentication-and-authorization-in-blazor-web-assembly)
.


## Conclusion

Thanks for reading! In this blog, we’ve outlined the process of integrating Google authentication into your Blazor WebAssembly app. Blazor WebAssembly simplifies authentication provider integration, ensuring your app’s security. For detailed guidance on authentication and authorization, consult the official Blazor WebAssembly [documentation](https://learn.microsoft.com/en-us/aspnet/core/blazor/security/webassembly/?view=aspnetcore-7.0)
.

Syncfusion’s [Blazor component library](https://www.syncfusion.com/blazor-components)
 boasts over 85 responsive, lightweight components, perfect for modern web apps. The latest version of Essential Studio® is available for existing customers on the [License and Downloads](https://www.syncfusion.com/account/downloads)
. If you’re new to Syncfusion, test our controls’ features with a 30-day [free trial](https://www.syncfusion.com/downloads)
.

If you have inquiries, contact us via our [support forum](https://www.syncfusion.com/forums)
, [support portal](https://support.syncfusion.com/)
, or [feedback portal](https://www.syncfusion.com/feedback/)
. We’re committed to assisting you!

## Related blogs

- [Pro Annotations on Mobile PDFs with Blazor PDF Viewer](https://www.syncfusion.com/blogs/post/mobile-pdf-annotations-with-blazor)
- [Seamlessly Add Blazor Native UI Components in Hybrid Apps](https://www.syncfusion.com/blogs/post/add-blazor-component-in-hybrid-apps)
- [Efficiently Perform CRUD Actions in the Blazor DataGrid with GraphQL](https://www.syncfusion.com/blogs/post/crud-actions-blazor-datagrid-graphql)
- [Boost Your Data Analysis: Best Practices for Optimizing Syncfusion Blazor Pivot Table Performance](https://www.syncfusion.com/blogs/post/tips-optimize-blazor-pivot-table)
