> ## Documentation Index
> Fetch the complete documentation index at: https://docs.apowerb.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Google Callback

> Complete the Google OAuth flow for a specific Google service.

The frontend calls this after Google redirects back to the callback page
with a temporary ``code``. This endpoint:
  1. Validates the requested service
  2. Validates the CSRF ``state`` against the server-side store
  3. Exchanges the code for access + refresh tokens
  4. Fetches the Google user profile
  5. Upserts the integration row with provider=service
  6. Resets the in-memory token state for that service module
  7. Returns basic integration info (never the raw token)



## OpenAPI

````yaml /api-reference/openapi.json post /api/integrations/google/callback
openapi: 3.1.0
info:
  title: apowerb API
  description: REST API of the apowerb agentic framework (open-source edition).
  version: 0.1.2
  license:
    name: MIT
    url: https://github.com/apowerb/apowerb/blob/main/LICENSE
servers:
  - url: https://api.example.com
    description: Your apowerb instance
  - url: http://localhost:8000
    description: Local stack
security: []
paths:
  /api/integrations/google/callback:
    post:
      tags:
        - integrations
      summary: Google Callback
      description: |-
        Complete the Google OAuth flow for a specific Google service.

        The frontend calls this after Google redirects back to the callback page
        with a temporary ``code``. This endpoint:
          1. Validates the requested service
          2. Validates the CSRF ``state`` against the server-side store
          3. Exchanges the code for access + refresh tokens
          4. Fetches the Google user profile
          5. Upserts the integration row with provider=service
          6. Resets the in-memory token state for that service module
          7. Returns basic integration info (never the raw token)
      operationId: google_callback_api_integrations_google_callback_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GoogleCallbackRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: {}
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    GoogleCallbackRequest:
      properties:
        code:
          type: string
          title: Code
        state:
          type: string
          title: State
        service:
          type: string
          title: Service
        redirect_uri:
          anyOf:
            - type: string
            - type: 'null'
          title: Redirect Uri
      type: object
      required:
        - code
        - state
        - service
      title: GoogleCallbackRequest
      description: Payload the frontend POSTs after Google redirects back.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````

## Related topics

- [Integrations](/guides/integrations.md)
- [Gmail webhooks](/guides/webhooks-gmail.md)
- [Google Connect](/api-reference/integrations/google-connect.md)
- [Github Callback](/api-reference/integrations/github-callback.md)
- [Oauth Callback](/api-reference/emailing/oauth-callback.md)
