Generating the authentication token Using OAuth 2.0 for calling Google developer API

Aleena George 30 Reputation points
2024-10-03T13:02:47.5633333+00:00

I am trying to generate the authentication token using OAuth 2.0 for the .NET MAUI application using the Google Cloud Console project to call the Google Developer API. For that, I created the project on the Google Cloud console, enabled the Google developer API and configured the consent screen with an external app type, created the OAuth 2.0 client ID with application type Android, and added the package name and SHA-1 fingerprint. I installed the NuGet packages below for the MAUI project.

  1. Microsoft.Identity.Client
  2. System.Net.Http.Json.

I added the below code to implement the OAuth flow on the MAUI Project.

        

On MainActivity.cs:

public

On AndroidManifest.xml:

<activity android:name="MainActivity"
  android:exported="true">

To generate the access token from the below function I calling the GoogleAuthService();

private

If I click on LoginButton, It navigates to the Microsoft login page, and If I try to log in with mail, it shows the below error.

We're unable to complete your request unauthorized_client: The client does not exist or is not enabled for consumers. If you are the application developer, configure a new application through the App Registrations in the Azure Portal at https://go.microsoft.com/fwlink/?linkid=2083908.

Screenshot:

ImportedPhoto_1727944061988

So, I am unable to generate the authentication token using OAuth 2.0. Is this process correct? How can I generate the authentication token to call the Google Developer API for .NET MAUI Apllication?

Please suggest a solution for this.

Developer technologies .NET .NET MAUI
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 50,126 Reputation points Microsoft External Staff
    2024-10-04T02:58:40.8633333+00:00

    Hello,

    We're unable to complete your request unauthorized_client: The client does not exist or is not enabled for consumers. If you are the application developer, configure a new application through the App Registrations in the Azure Portal at https://go.microsoft.com/fwlink/?linkid=2083908.

    This error message is usually caused by the Azure side not configuring the account authentication correctly.

    In the Q&A, some users have encountered the same error message and solved the problem by configuring Manifest.

    You could refer to unauthorized_client: The client does not exist or is not enabled for consumers for more detailed information.

    Best Regards,

    Alec Liu.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. Bruce (SqlWork.com) 77,686 Reputation points Volunteer Moderator
    2024-10-14T16:35:09.0766667+00:00

    You appear to be trying to use azure to get the token, but you need to use googles oauth server.

    https://developers.google.com/identity/protocols/oauth2

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.