Gå till huvudinnehållet Gå till huvudmenyn

Creating a Google Service Account

Before AI Assistant can access Google APIs, you need to create a service account in Google Cloud Console. A service account represents your application (not a user) and is used for secure, programmatic access to services such as: Google Search Console, Google Analytics. All access is performed using a service account under your control, ensuring that your data remains secure and is never shared with or transferred to third parties.

Steps to Create a Service Account

1. Create a Google Cloud Project (Skip if already exists)

If you already have a project in Google Cloud Console, you can skip this step. Otherwise:

  1. Go to Google Cloud Console
  2. Click Select Project → New Project
  3. Provide: Project Name
  4. Click Create

2. Enable Required APIs

Navigate to APIs & Services → Library, then enable:

For Search Console: Search Console API
For Analytics (GA4): Google Analytics Data API, Google Analytics Admin API.

3. Create a Service Account

  1. Go to IAM & Admin → Service Accounts
  2. Click Create Service Account
  3. Fill: Name, ID (auto-generated)
  4. Click Create and Continue
  5. Roles: You can skip assigning roles here
  6. Click Done

4. Generate Service Account Key

  1. Open the created service account
  2. Go to Keys → Add Key → Create new key
  3. Choose: JSON 
  4. Download the file

⚠️ This JSON file contains credentials - you should store it securely. 

5. Grant Access in Google Search Console

  1. Go to Google Search Console
  2. Select your property (domain or URL prefix)
  3. Go to Settings → Users and permissions
  4. Click Add User
  5. Add the service account email (e.g. your-account-name@project.iam.gserviceaccount.com)
  6. Assign role: Full

6. Grant Access in Google Analytics (GA4)

  1. Go to Google Analytics
  2. Navigate:
    • Admin → Property Access Management
  3. Click + → Add users
  4. Add the service account email
  5. Assign role: Analyst

Configure the Service Account in Your Application

Once the service account is created and permissions are granted, configure it in your application settings.

Example: Configure service account in appsettings.json

"Epinova": {
     "GoogleServices": {
      "Accounts": [
        {
          "ClientEmail": "epinova-ai-assistant@epinova-internal.iam.gserviceaccount.com",
          "PrivateKey": "-----BEGIN PRIVATE KEY----- xxxxxxx -----END PRIVATE KEY-----\n"
        }
      ]
    }
}

Notes

  • Ensure the private key preserves line breaks (\n)
  • Prefer storing secrets in:
    • Environment variables
    • Secret managers (e.g., Azure Key Vault)
  • Avoid hardcoding credentials in source code