---
title: "Login to API using Figma OAuth"
method: GET
path: "/login/"
tags: ["Authentication"]
---

# Login to API using Figma OAuth

`GET /login/`

## Request

- Base URL: `http://api.cannoli.app/api/v1`
- URL: `http://api.cannoli.app/api/v1/login/`
- Auth: none declared

### Token creation
User Authentication and creation is done through Figma's OAuth2. When you request this endpoint you will first
receive a URL to allow the user to give access to Cannoli with a pre-configured redirect uri. You can override
this through the `redirect_uri` GET parameter:

    /api/v1/login/?redirect_uri=<YOUR_REDIRECT_URI>

In order to complete the authentication process Figma returns a code which is used by the backend to complete
the handshake process. If you want to login through a separate frontend you need to override the `redirect_uri`, 
receive the `code` and send it back to this endpoint along with the `redirect_uri` you configured:

    /api/v1/login/?redirect_uri=<YOUR_REDIRECT_URI>&code=<CODE_FROM_FIGMA> 

Once you complete the authentication process you'll receive a jwt token to authenticate with the API. The 
`access_token` has a lifetime of 30 minutes and the `refresh_token` has a lifetime of 7 days.

### Authenticating with the API once you have your token
Once you complete the authentication procces you must send your `access_token` as a Bearer header:

    curl -H "Content-Type: application/json" -H "Authorization: Bearer <YOUR_ACCESS_TOKEN>" \
    https://api-dev.cannoli.app/api/v1/figma/files/

## Query parameters

- `code` string
- `redirect_uri` string

## Response `200`

User login response

- FigmaLogin
  - `user` User, required
    - `id` integer
    - `username` string: Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.
    - `first_name` string
    - `last_name` string
    - `email` string, email
    - `figma_email` string, email
    - `avatar` string, uri, nullable
    - `default_font` integer, nullable
    - `is_pro_user` string
    - `is_team_user` string
    - `can_create_more_files` string
    - `is_vip` string
    - `teams` Team[], required
      - `id` integer
      - `name` string, required
      - `organization` string
      - `owner` string
      - `permission` string
      - `logo` string, uri, nullable
      - `can_add_more_members` string
      - `projects` Project[]
        - `id` integer
        - `name` string, required
        - `team_id` string
        - `team_name` string
        - `created_at` string, date-time
        - `last_updated_at` string, date-time
    - `team_subscriptions` Subscription[], required
      - `id` integer
      - `seats` integer
      - `tier` 'F' | 'P' | 'T'
      - `status` 'A' | 'O' | 'P' | 'C'
      - `current_period_start` string, date-time, nullable
      - `current_period_end` string, date-time, nullable
      - `team` integer, nullable
      - `user` integer, nullable
    - `subscriptions` Subscription, required
      - `id` integer
      - `seats` integer
      - `tier` 'F' | 'P' | 'T'
      - `status` 'A' | 'O' | 'P' | 'C'
      - `current_period_start` string, date-time, nullable
      - `current_period_end` string, date-time, nullable
      - `team` integer, nullable
      - `user` integer, nullable
    - `trial_end_date` string, date-time
    - `trial_start_date` string, date-time
    - `has_valid_trial` string
    - `trial_days_left` string
    - `is_elegible_for_trial` string
  - `access_token` string, required
  - `refresh_token` string, required
  - `access_token_expires_in` number, required
  - `refresh_token_expires_in` number, required

---

[API](https://skmtc.dev/cannoli/apis/cannoli-backend-api.md) - [All operations](https://skmtc.dev/cannoli/apis/cannoli-backend-api/llms.txt) - [OpenAPI document](https://skmtc.dev/cannoli/apis/cannoli-backend-api/revisions/d27aef14fd7a?raw)
