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

> Logs a user in.

# Login User

```
url = `https://codecombat.com/auth/login-o-auth?provider=${OAUTH_PROVIDER_ID}&accessToken=1234`
res.redirect(url)
// User is sent to this CodeCombat URL and assuming everything checks out,
// is logged in and redirected to the home page.
```

In this example, we call your lookup URL (let’s say,
`https://oauth.provider/user?t=<%= accessToken %>`) with the access token
(1234). The lookup URL returns `{ id: 'abcd' }` in this case. We will match this
id with the OAuthIdentity stored in the user information in our db. If
everything checks out, the user is logged in and redirected to the home page.


## OpenAPI

````yaml GET /auth/login-o-auth
openapi: 3.0.1
info:
  title: CodeCombat API
  version: 0.0.1
servers:
  - url: https://codecombat.com/api
    description: default
security: []
paths:
  /auth/login-o-auth:
    get:
      tags:
        - Auth
      summary: Login User
      description: >
        Logs a user in. In this example, we call your lookup URL (let's say,
        `https://oauth.provider/user?t=<%= accessToken %>`) with the access
        token (`1234`). The lookup URL returns `{ id: 'abcd' }` in this case. We
        will match this `id` with the OAuthIdentity stored in the user
        information in our db. If everything checks out, the user is logged in
        and redirected to the home page.
      operationId: auth_loginOauth
      parameters:
        - name: provider
          in: query
          description: Your OAuth Provider ID
          required: true
          schema:
            type: string
        - name: accessToken
          in: query
          description: >-
            Will be passed through your lookup URL to get the user ID. Required
            if no `code`.
          required: false
          schema:
            type: string
            nullable: true
        - name: code
          in: query
          description: >-
            Will be passed to the OAuth token endpoint to get a token. Required
            if no `accessToken`.
          required: false
          schema:
            type: string
            nullable: true
        - name: redirect
          in: query
          description: >-
            Override where the user will navigate to after successfully logging
            in.
          required: false
          schema:
            type: string
            nullable: true
        - name: errorRedirect
          in: query
          description: >-
            If an error happens, redirects the user to this url, with at least
            query parameters `code`, `errorName` and `message`.
          required: false
          schema:
            type: string
            nullable: true
      responses:
        '204':
          description: ''
      security:
        - BasicAuth: []
components:
  securitySchemes:
    BasicAuth:
      type: http
      scheme: basic

````