Back to Capabilities

OAuth Connections

OAuth integrations with multiple providers, automatic token refresh, and AES-256 credential encryption.

Imagine...

Your customer data lives in Stripe. Support conversations in Intercom. Usage analytics from your app. Sales pipeline in Salesforce. Team chat in Slack. Nothing talks to each other.

"Who are our best customers?" means logging into 5 different services and piecing it together manually.

You

"Connect Stripe, Intercom, and Salesforce. Pull all customer data into one place so I can actually see what's happening."

Your Awareness

*Sets up OAuth flows, guides you through authorization, creates sync workflows*

"Connected. I'm syncing customer data from all three services into your database. It'll refresh every hour. You now have a unified customer table with payment history, support tickets, and deal status."

You

"When a customer upgrades their plan in Stripe, post a celebration message in our #wins Slack channel and update their status in Salesforce."

Your Awareness

*Connects to Slack workspace, creates webhook-triggered workflow listening to Stripe events*

"Done. Every time someone upgrades, your team gets notified and Salesforce updates automatically. Want to test it?"

You

"Also, if a high-value customer opens a support ticket, alert me immediately."

Your Awareness

"Added. You'll get a direct Slack message whenever customers paying >$500/mo open a ticket. Should include their account details?"

This isn't magic. This is collaboration.

Connect your tools once. Let data flow automatically. Stop switching between 20 browser tabs.

Supported Providers

Google

Gmail, Calendar, Drive, Sheets

  • • gmail.send - Send emails
  • • gmail.readonly - Read emails
  • • calendar.events - Manage calendar
  • • drive.readonly - Access Drive files

GitHub

Repos, Issues, PRs, Actions

  • • repo - Full repository access
  • • read:org - Read organization data
  • • workflow - GitHub Actions
  • • user - User profile

Microsoft

Office 365, Teams, OneDrive

  • • Mail.ReadWrite - Outlook email
  • • Calendars.ReadWrite - Calendar
  • • Files.ReadWrite.All - OneDrive
  • • Team.ReadBasic.All - Teams

Slack

Messages, Channels, Files

  • • chat:write - Send messages
  • • channels:read - List channels
  • • files:write - Upload files
  • • users:read - User info

Notion

Pages, Databases, Blocks

  • • Read content
  • • Update pages and databases
  • • Create pages
  • • Search workspace

Linear

Issues, Projects, Teams

  • • Read issues and projects
  • • Create and update issues
  • • Manage labels
  • • Webhooks

Connection Flow

1

Initiate Connection

User or AI calls connect_service with provider and scopes.

connect_service({
  provider: "google",
  scopes: ["https://www.googleapis.com/auth/gmail.send"],
  redirectUri: "https://app.awareness.com/api/connections/callback"
})
2

Authorization URL

Tool returns an authorization URL. User opens it in browser and grants permissions.

3

OAuth Callback

Provider redirects to callback URL with authorization code. Server exchanges code for access/refresh tokens.

4

Token Storage

Tokens are encrypted with AES-256 and stored in the Connection table. Connection status becomes "active".

5

Usage

Tools like gmail_send or github_create_issue automatically fetch tokens and make API calls.

Automatic Token Refresh

Access tokens expire after 1 hour (Google) or variable periods (other providers). The system automatically refreshes tokens before they expire:

// Automatic refresh flow
1. Tool (e.g., gmail_send) requests access token
2. ConnectionLookup checks expiresAt timestamp
3. If expired and refreshToken exists:
   a. Call provider token endpoint with refresh_token grant
   b. Get new access_token and expiresAt
   c. Update Connection record in database
4. Return fresh access token to tool

// Providers with refresh support:
- Google (3600s expiry)
- GitHub (no expiry, but can be revoked)
- Microsoft (3600s expiry)
- Slack (no expiry)

// Fallback for expired tokens without refresh:
- Connection status becomes "expired"
- User must re-authenticate

Token refresh is transparent to workflows and users. Failed refreshes mark the connection as "expired" and require re-authentication.

Security

Encryption

  • • AES-256-GCM encryption for tokens
  • • Unique encryption key per environment
  • • Keys stored in secure environment variables
  • • No plaintext tokens in database

Access Control

  • • User-scoped connections (userId field)
  • • Space isolation via user scoping
  • • Minimum scopes principle
  • • Token revocation on disconnect

Audit

  • • Connection creation timestamps
  • • Tool execution logs with connection IDs
  • • Token refresh events
  • • Failed auth attempts

HMAC Verification

  • • Webhook signatures validated
  • • Prevent replay attacks
  • • Configurable secrets per workflow
  • • GitHub, Slack signature formats supported

Example: Gmail Send Email

// Step 1: Connect Gmail (one-time)
connect_service({
  provider: "google",
  scopes: [
    "email",
    "profile",
    "https://www.googleapis.com/auth/gmail.send"
  ],
  redirectUri: "https://app.awareness.com/api/connections/callback"
})
// Returns: { authorizationUrl: "https://accounts.google.com/o/oauth2/v2/auth?..." }

// User opens URL, grants permissions, redirects back
// Connection is now active

// Step 2: Send email (automatic token lookup)
gmail_send({
  to: "user@example.com",
  subject: "Report Ready",
  body: "Your daily report is attached.",
  attachments: [
    { filename: "report.pdf", content: "base64_encoded_pdf" }
  ]
})

// Behind the scenes:
// 1. ConnectionLookup fetches Google connection for current user
// 2. If token expired, automatically refreshes
// 3. Makes Gmail API call with fresh token
// 4. Returns success/failure

// Step 3: List connections
list_connections()
// Returns: [
//   { provider: "google", displayName: "user@gmail.com", status: "active", createdAt: "..." },
//   { provider: "github", displayName: "username", status: "active", createdAt: "..." }
// ]

// Step 4: Disconnect (revoke tokens)
disconnect_service({ connectionId: "userId:google" })

Integration Tools

Once connected, these tools become available for workflows and AI:

Gmail Tools

  • gmail_list - List messages with query
  • gmail_get - Get message by ID
  • gmail_send - Send email with attachments

GitHub Tools

  • github_list_repos - List user repos
  • github_get_repo - Get repo details
  • github_list_issues - List issues
  • github_list_prs - List pull requests
  • github_create_issue - Create issue
  • github_get_user - Get user info

Connection Management Tools

list_connections

List user's active connections

list_connection_providers

List available OAuth providers

connect_service

Initiate OAuth flow for provider

disconnect_service

Revoke connection and delete tokens

get_connection_status

Check connection health