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

# Create an auth token via OAuth.

> Create a short-term authentication token using a third-party OAuth provider (e.g., Google).



## OpenAPI

````yaml /api-spec/ias-public-api.yaml post /me/oauth/auth-tokens
openapi: 3.0.3
info:
  title: IAM Service API
  description: APIs for IAM Service.
  version: 2.4.0
servers:
  - url: https://console.gmicloud.ai/api/v1
    description: IAM Service API
security: []
paths:
  /me/oauth/auth-tokens:
    post:
      tags:
        - me
      summary: Create an auth token via OAuth.
      description: >-
        Create a short-term authentication token using a third-party OAuth
        provider (e.g., Google).
      operationId: createAuthTokenOAuth
      requestBody:
        description: The request body for creating an auth token via OAuth.
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/createOAuthAuthTokenRequest'
      responses:
        '201':
          description: Successfully created an auth token for user via OAuth.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/createOAuthAuthTokenResponse'
        '400':
          description: >
            - [group:**oauth**, code:**0**]: Unsupported OAuth provider.

            - [group:**oauth**, code:**1**]: Invalid access token.

            - [group:**request**, code:**0**]: Invalid field in the request
            body.

            - [group:**request**, code:**1**]: The request body is required.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrStatusMsg'
              examples:
                Invalid field in the request body:
                  summary: Invalid field in the request body.
                  value:
                    group: request
                    code: 0
                    validationDetail:
                      - field: provider
                        expression: required
                        originalValue: ''
                        reason: This field is required.
                The request body is required:
                  summary: The request body is required.
                  value:
                    group: request
                    code: 1
                    message: The request body is required.
        '404':
          description: |
            - [group:**user**, code:**1**]: User does not exist.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrStatusMsg'
              examples:
                User does not exist:
                  summary: User does not exist.
                  value:
                    group: user
                    code: 0
                    message: User does not exist.
        '500':
          description: |
            - [group:**oauth**, code:**1000**]: Get user info encountered error.
            - [group:**session**, code:**200**]: Failed to create auth token.
            - [group:**session**, code:**201**]: Failed to save auth token data.
            - [group:**user**, code:**1200**]: Get user encountered DB error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrStatusMsg'
              examples:
                Failed to create auth token:
                  summary: Failed to create auth token.
                  value:
                    group: session
                    code: 200
                    message: Failed to create auth token.
                    traces:
                      - error occurred.
components:
  schemas:
    createOAuthAuthTokenRequest:
      type: object
      x-go-name: createOAuthAuthTokenRequest
      properties:
        provider:
          type: string
          description: |
            The authentication provider used for login.
            - "google": User logs in with Google OAuth.
            - "github": User logs in with Github OAuth.
            - "hugging_face": User logs in with Hugging Face OAuth.
          enum:
            - google
            - github
            - hugging_face
          example: google
          x-go-type: iamLibTypes.OAuthProvider
          x-go-type-import:
            path: us-central1-go.pkg.dev/gmi-cloud-cicd/go-dev/iam-lib-go/pkg/types
            name: iamLibTypes
          x-oapi-codegen-extra-tags:
            binding: required
        accessToken:
          type: string
          description: OAuth access token (e.g., Google).
          example: ya29.a0AfH6SMB...
          x-oapi-codegen-extra-tags:
            binding: required
      required:
        - provider
        - accessToken
    createOAuthAuthTokenResponse:
      type: object
      x-go-name: createOAuthAuthTokenResponse
      properties:
        authToken:
          type: string
          description: >-
            A temporary token issued  after the initial login step. This token
            is used in the create session API to exchange for access and refresh
            tokens.
          example: eyJhbGciOiJIUzI1NiIsInR...
      required:
        - authToken
    ErrStatusMsg:
      type: object
      properties:
        group:
          type: string
          description: >-
            API function group\n -Will be "request" if there are invalid request
            parameters.
          x-oapi-codegen-extra-tags:
            binding: required
        code:
          type: integer
          description: The substatus error code for the API response.
          x-oapi-codegen-extra-tags:
            binding: required
        message:
          type: string
          description: The substatus error Message for API response.
          x-go-type-skip-optional-pointer: true
        traces:
          type: array
          items:
            type: string
          description: The original error messages.
          x-go-type-skip-optional-pointer: true
        validationDetail:
          type: array
          items:
            $ref: '#/components/schemas/ValidationDetail'
          description: >-
            Returned when there are invalid request
            paremeters(group="request")\n List of invalid fields and the reason
            of error.
          x-go-type-skip-optional-pointer: true
      example:
        group: request
        code: 0
        validationDetail:
          - field: email
            expression: required
            originalValue: ''
            reason: This field is required.
      required:
        - group
        - code
    ValidationDetail:
      type: object
      properties:
        field:
          type: string
          description: The field of the request data.
          x-go-type-skip-optional-pointer: true
        expression:
          type: string
          description: The form of violation.
          x-go-type-skip-optional-pointer: true
        argument:
          type: string
          description: The number or data to support the expression.
          x-go-type-skip-optional-pointer: true
        originalValue:
          description: The original value from the request.
          x-go-type-skip-optional-pointer: true
        reason:
          type: string
          description: The reason for the validation error.
          x-go-type-skip-optional-pointer: true
      example:
        - field: fieldXXX
          expression: required
          originalValue: ''
          reason: This field is required.

````