AgentSkillsCN

using-oauth-integrations

在 inference.sh 应用中集成 OAuth。当您需要代表用户访问 Google Sheets、Drive,或其他 OAuth 服务时,可使用此技能。

SKILL.md
--- frontmatter
name: using-oauth-integrations
description: Use OAuth integrations in inference.sh apps. Use when accessing Google Sheets, Drive, or other OAuth services on behalf of users.

Using OAuth Integrations

Access external services (Google Sheets, Drive) on behalf of users through OAuth.

Declaring Integrations

In inf.yml:

yaml
integrations:
  - key: google.sheets
    description: Read/write Google Sheets
    optional: false

  - key: google.drive
    description: Access to Google Drive files
    optional: true

Properties

PropertyTypeDescription
keystringIntegration identifier
descriptionstringShown to users
optionalbooleanIf false, app won't run without it

Available Integrations

bash
infsh integrations list
KeyDescription
google.sheetsRead/write Sheets
google.sheets.readonlyRead-only Sheets
google.driveGoogle Drive files
google.saService account

Accessing Credentials

OAuth Integrations

python
import os, json

class App(BaseApp):
    async def setup(self, config):
        creds_json = os.environ.get("GOOGLE_OAUTH_CREDENTIALS")
        if creds_json:
            self.credentials = json.loads(creds_json)

Service Account

python
from google.oauth2 import service_account

class App(BaseApp):
    async def setup(self, config):
        sa_json = os.environ.get("GOOGLE_SA_CREDENTIALS")
        if sa_json:
            self.credentials = service_account.Credentials.from_service_account_info(
                json.loads(sa_json)
            )

Secrets vs Integrations

FeatureSecretsIntegrations
User providesRaw value (API key)OAuth authorization
RefreshManualAutomatic
Scope controlNoneFine-grained
Best forAPI keysOAuth services

Best Practices

  1. Request minimal scopes - use readonly if you only read
  2. Clear descriptions - explain why access is needed
  3. Handle missing gracefully - check if optional integrations exist