Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Google auth oauth2 in .net MAUI

Good day everyone. I am brand new to developing IOS applications and I am attempting to use Visual Studio .Net Maui with.net Core 8 to connect up my local device and debug my application. This is successful, however I am attempting to find a working example of using the google auth oAuth 2.0 API to validate a google user and return back to the application. I don't think this is that difficult however it appears that the callback is not being set up correctly in Google Auth API.

Every video example I've found has some form of issue.  If anyone has any suggested video which accomplishes this with .net 8 core and MAUI I'd be forever grateful.

Has anyone successfully done this with .net Maui and C# in Visual Studio 2022?

0 1 517
1 REPLY 1

Hi @dancolgan,

Welcome to Google Cloud Community!

Incorporating Google OAuth 2.0 into a .NET MAUI application can be challenging because of platform-specific details, particularly concerning the callback URL setup. Here are a few of my suggestion/s:

  1. Set up OAuth in Google Cloud Console:
    - Create an OAuth 2.0 client ID and use a redirect URI like com.yourapp:/oauth2redirect.
    - Add this URI in the console, and ensure it matches your app configuration.
  2. Use an OAuth library:
    Use libraries like IdentityModel.OidcClient or Xamarin.Auth to handle OAuth flows.
  3. Test the redirect:
    Ensure your app package name matches the Google Cloud settings, and check logs to confirm the callback URL is being invoked.

 You may be able to integrate Google OAuth 2.0 into your .NET MAUI app by trying those recommendation/s. Hoping this would be helpful!

 

 

 

Top Labels in this Space