Google chrome extension Manifest version 3 to handle Google sign-in's

Viewed 299

I'm new at dealing with Chrome extensions, and I need to use Manifest version 3 to handle Google sign-ins on Chrome extensions. Once signed-in, I need to store user data on chrome storage as well. Can any one assist me with this? Thanks in advance.

1 Answers

Currently, with manifest v3 we cannot use the google sign popup for authorizing users. We should be using chrome.identity API for authenticating the users with OAuth2 API services. I have used the google cloud platform to create the Oauth2 client id and token. Let me show you step by step process :

  1. Create a project with google cloud

  2. After creating the project you must create credentials for that project. Go to the credentials section and choose OAuth client ID
    enter image description here.

  3. Next step is to get your extension id which can be easily found on the chrome://extensions page enter image description here

  4. Now in "Create OAuth client id" section,choose “Chrome app” as the application type for the OAuth 2.0 client, and paste your extension ID into the Application ID field enter image description here

  5. After creating it, you will get the client_id which needs to be used in our manifest.json file.

"oauth2": {
        "client_id": "<YOUR_CLIENT_ID>.apps.googleusercontent.com",
        "scopes": []
      }
  1. To access the chrome.identity API in your chrome extension, add identity as in the permissions section

"permissions": [ "identity" ]

  1. Finally, you can trigger the API by using the following method

     chrome.identity.getAuthToken({ 'interactive': true }, function (token) {
        console.log(token);
      });

For further information , please checkout the article here

Related