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

# Log In

> Upgrades an application session to a user session.

#### Recipes

<AccordionGroup>
  <Accordion title="Log in with login and password">
    <Steps>
      <Step title="1. Set the login">
        Set your login here.

        ```curl {5} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: cf5709d6013fdb7a6787fbeb8340afed8aec4c69" \
        -d '{  
          "login":"Andrew",
        }' \
        https://api.quickblox.com/login.json
        ```
      </Step>

      <Step title="2. Set the password">
        Set your password here.

        ```curl {6} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: cf5709d6013fdb7a6787fbeb8340afed8aec4c69" \
        -d '{  
          "login":"Andrew",
          "password":"mypassword"
        }' \
        https://api.quickblox.com/login.json
        ```
      </Step>

      <Step title="3. As a result, the API returns a logged in user.">
        ```json theme={null}
        {
          "user": {
            "id": 96705448,
            "full_name": "Andrew Lee",
            "email": "andrew@gmail.com",
            "login": "Andrew",
            "phone": "+9923474236",
            "website": "https://myapp.com",
            "created_at": "2019-08-26T20:53:42Z",
            "updated_at": "2019-08-26T21:38:38Z",
            "last_request_at": "2019-08-26T21:38:44Z",
            "external_user_id": null,
            "facebook_id": "89987878",
            "blob_id": null,
            "custom_data": null,
            "age_over16": true,
            "allow_statistics_analysis": false,
            "allow_sales_activities": false,
            "parents_contacts": "",
            "user_tags": "admin,co-workers,design"
          }
        }
        ```
      </Step>
    </Steps>
  </Accordion>

  <Accordion title="Log in with Firebase phone number">
    <Steps>
      <Step title="1. Set a social network provider">
        Set a `firebase_phone` as a social network provider.

        ```curl {5} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 4b8d6b42d030ac4fc4251f9d0070ca5faa012bba" \
        -d '{  
          "provider":"firebase_phone",
        }' \
        https://api.quickblox.com/login.json
        ```
      </Step>

      <Step title="2. Use a `firebase_phone` parameter to set Firebase data">
        ```curl {6-7} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 4b8d6b42d030ac4fc4251f9d0070ca5faa012bba" \
        -d '{  
          "provider":"firebase_phone",
          "firebase_phone":{  
          }
        }' \
        https://api.quickblox.com/login.json
        ```
      </Step>

      <Step title="3. Set Firebase project ID">
        Use a `project_id` parameter to set Firebase project ID.

        ```curl {7} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 4b8d6b42d030ac4fc4251f9d0070ca5faa012bba" \
        -d '{  
          "provider":"firebase_phone",
          "firebase_phone":{
            "project_id":"my_app_project_id",  
          }
        }' \
        https://api.quickblox.com/login.json
        ```
      </Step>

      <Step title="4. Set Firebase access token">
        Use an `access_token` parameter to set Firebase access token.

        An access token is a token received from the social network after a user authenticates with it.

        ```curl {8} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 4b8d6b42d030ac4fc4251f9d0070ca5faa012bba" \
        -d '{  
          "provider":"firebase_phone",
          "firebase_phone":{
            "project_id":"my_app_project_id",
            "access_token":"t35400dfzxcxvsdfn"  
          }
        }' \
        https://api.quickblox.com/login.json
        ```
      </Step>

      <Step title="5. As a result, the API returns the logged in user.">
        ```json theme={null}
        {
          "user": {
            "id": 96705448,
            "full_name": "Andrew Lee",
            "email": "andrew@gmail.com",
            "login": "Andrew",
            "phone": "+9923474236",
            "website": "https://myapp.com",
            "created_at": "2019-08-26T20:53:42Z",
            "updated_at": "2019-08-26T21:38:38Z",
            "last_request_at": "2019-08-26T21:38:44Z",
            "external_user_id": null,
            "facebook_id": "89987878",
            "blob_id": null,
            "custom_data": null,
            "age_over16": true,
            "allow_statistics_analysis": false,
            "allow_sales_activities": false,
            "parents_contacts": "",
            "user_tags": "admin,co-workers,design"
          }
        }
        ```
      </Step>
    </Steps>
  </Accordion>

  <Accordion title="Log in with Facebook access token">
    <Steps>
      <Step title="1. Set a social network provider">
        Use a `provider` param to set a social network provider.

        ```curl {5} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 4b8d6b42d030ac4fc4251f9d0070ca5faa012bba" \
        -d '{  
          "provider":"facebook",
        }' \
        https://api.quickblox.com/login.json
        ```
      </Step>

      <Step title="2. Use a `keys` parameter to set an access token">
        ```curl {6-7} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 4b8d6b42d030ac4fc4251f9d0070ca5faa012bba" \
        -d '{  
          "provider":"facebook",
          "keys":{  
          }
        }' \
        https://api.quickblox.com/login.json
        ```
      </Step>

      <Step title="3. Set an access token">
        An access token is a token received from the social network after a user authenticates with it.

        ```curl {7} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: 4b8d6b42d030ac4fc4251f9d0070ca5faa012bba" \
        -d '{  
          "provider":"facebook",
          "keys":{  
            "token":"AM46dxjhisdffgry26282352fdusdfusdfgsd"
          }
        }' \
        https://api.quickblox.com/login.json
        ```
      </Step>

      <Step title="4. As a result, the API returns a logged in user.">
        ```json theme={null}
        {
          "user": {
            "id": 96705448,
            "full_name": "Andrew Lee",
            "email": "andrew@gmail.com",
            "login": "Andrew",
            "phone": "+9923474236",
            "website": "https://myapp.com",
            "created_at": "2019-08-26T20:53:42Z",
            "updated_at": "2019-08-26T21:38:38Z",
            "last_request_at": "2019-08-26T21:38:44Z",
            "external_user_id": null,
            "facebook_id": "89987878",
            "blob_id": null,
            "custom_data": null,
            "age_over16": true,
            "allow_statistics_analysis": false,
            "allow_sales_activities": false,
            "parents_contacts": "",
            "user_tags": "admin,co-workers,design"
          }
        }
        ```
      </Step>
    </Steps>
  </Accordion>
</AccordionGroup>

After an application session has been created, lets your users to log in to their account with login/email
and password. There are the following login options available:

* Log in with login/email and password.
* Log in via Facebook.
* Log in via Firebase phone number (SMS).

#### Body Parameters

<ParamField body="login" type="string"> User login. </ParamField>

<ParamField body="email" type="string"> User email. </ParamField>

<ParamField body="password" type="string"> User password. </ParamField>

<ParamField body="provider" type="string"> Possible providers: `facebook`, `firebase_phone`. </ParamField>

<ParamField body="keys" type="object">
  <Expandable title="properties">
    <ParamField body="token" type="string"> Social network provider's access token. </ParamField>
    <ParamField body="secret" type="string"> Social network provider's access token secret. </ParamField>
  </Expandable>
</ParamField>

<ParamField body="firebase_phone" type="object">
  <Expandable title="properties">
    <ParamField body="project_id" type="string"> A unique identifier for your Firebase project. </ParamField>
    <ParamField body="access_token" type="string"> Firebase user's ID token. </ParamField>
  </Expandable>
</ParamField>

#### Headers

<ParamField header="QB-Token" type="string" required> A user or application session token. See [Authentication](/reference/authentication) page to learn more about session tokens. </ParamField>

#### Responses

<AccordionGroup>
  <Accordion title="202">
    A successful response

    <ResponseField name="user" type="object">
      <Expandable title="properties">
        <ResponseField name="id" type="integer" />

        <ResponseField name="full_name" type="string" />

        <ResponseField name="email" type="string" />

        <ResponseField name="login" type="string" />

        <ResponseField name="phone" type="string" />

        <ResponseField name="website" type="string" />

        <ResponseField name="created_at" type="string" />

        <ResponseField name="updated_at" type="string" />

        <ResponseField name="last_request_at" type="string" />

        <ResponseField name="external_user_id" type="string" />

        <ResponseField name="facebook_id" type="string" />

        <ResponseField name="blob_id" type="string" />

        <ResponseField name="custom_data" type="string" />

        <ResponseField name="age_over16" type="boolean" />

        <ResponseField name="allow_statistics_analysis" type="boolean" />

        <ResponseField name="allow_sales_activities" type="boolean" />

        <ResponseField name="parents_contacts" type="string" />

        <ResponseField name="user_tags" type="string" />
      </Expandable>
    </ResponseField>
  </Accordion>
</AccordionGroup>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST \
  -H "Content-Type: application/json" \
  -H "QB-Token: cf5709d6013fdb7a6787fbeb8340afed8aec4c69" \
  -d '{  
    "login":"Andrew",
    "password":"mypassword"
  }' \
  https://api.quickblox.com/login.json
  ```
</RequestExample>

<ResponseExample>
  ```json 202 theme={null}
  {
    "user": {
      "id": 96705448,
      "full_name": "Andrew Lee",
      "email": "andrew@gmail.com",
      "login": "Andrew",
      "phone": "+9923474236",
      "website": "https://myapp.com",
      "created_at": "2019-08-26T20:53:42Z",
      "updated_at": "2019-08-26T21:38:38Z",
      "last_request_at": "2019-08-26T21:38:44Z",
      "external_user_id": null,
      "facebook_id": "89987878",
      "blob_id": null,
      "custom_data": null,
      "age_over16": true,
      "allow_statistics_analysis": false,
      "allow_sales_activities": false,
      "parents_contacts": "",
      "user_tags": "admin,co-workers,design"
    }
  }
  ```
</ResponseExample>
