# Log in as User

- Operation ID: `userLogin`
- HTTP method: `POST`
- Path: `/uauth/auth/login/user`
- [Human-readable API reference](https://hub.synerise.com/api-reference/authorization#tag/Authorization/operation/userLogin)

## Self-contained OpenAPI method

The fenced document below contains this method's documentation and all of its local references. It is self-contained; no category or master specification fetch is required.

```yaml
openapi: 3.0.0
info:
  title: Synerise Public API
  version: 1.9.1
paths:
  /uauth/auth/login/user:
    post:
      tags:
        - Authorization
      summary: Log in as User
      description: |
        Authenticate as a User.

        **Note:** To perform operations within a Workspace, you must [select a Workspace](#operation/userProfileLoginUsingPOST).

        ---

        **Authentication:** Not required
      operationId: userLogin
      requestBody:
        content:
          application/json:
            schema:
              required:
                - password
                - username
              type: object
              properties:
                username:
                  type: string
                  description: The login (email address) of the user
                password:
                  type: string
                  description: The user's password
                deviceId:
                  type: string
                  description: Identifier of user's current device
                externalProviderToken:
                  type: string
                externalProviderType:
                  type: string
                  enum:
                    - GOOGLE
                organizationName:
                  type: string
                  description: Optional organization name for login context
        required: true
      responses:
        "200":
          description: Login details
          content:
            application/json:
              schema:
                required:
                  - consumer
                type: object
                properties:
                  consumer:
                    type: object
                    description: Details of the authenticated user
                    properties:
                      type:
                        type: string
                        enum:
                          - USER
                      businessProfileId:
                        type: integer
                        description: ID of the selected workspace
                      name:
                        type: string
                        description: The user's login
                      id:
                        type: integer
                        description: ID of the user
                      authorities:
                        type: array
                        description: A list of permissions
                        items:
                          type: string
                      roles:
                        type: string
                        description: IDs of the roles assigned to the user
                  mfaMethods:
                    type: array
                    items:
                      type: string
                      enum:
                        - TOTP_AUTHENTICATOR
                        - EMAIL
                        - SMS
                  authorizationError:
                    type: string
                    enum:
                      - USER_FORCED_TO_CHANGE_PASSWORD
                  multiFactorCodeSent:
                    type: object
                    properties:
                      method:
                        type: string
                        enum:
                          - TOTP_AUTHENTICATOR
                          - EMAIL
                      status:
                        type: string
                        enum:
                          - OK
                          - LIMIT_REACHED
                          - ERROR
                      nextTryInSeconds:
                        type: integer
                        format: int32
                  defaultMfaMethod:
                    type: string
                    enum:
                      - TOTP_AUTHENTICATOR
                      - EMAIL
                      - SMS
                  forcedToSetMfa:
                    type: boolean
        "401":
          description: Unauthorized
          content: {}
        "403":
          description: Forbidden
          content: {}
        "404":
          description: Not Found
          content: {}
      x-snr-doc-urls:
        - /api-reference/authorization#tag/Authorization/operation/userLogin
      x-codeSamples:
        - lang: cURL
          label: cURL
          source: |-
            curl --request POST \
              --url https://api.synerise.com/uauth/auth/login/user \
              --header 'content-type: application/json' \
              --data '{"username":"string","password":"string","deviceId":"string","externalProviderToken":"string","externalProviderType":"GOOGLE","organizationName":"string"}'
        - lang: Python
          label: Python
          source: |-
            import http.client

            conn = http.client.HTTPSConnection("api.synerise.com")

            payload = "{\"username\":\"string\",\"password\":\"string\",\"deviceId\":\"string\",\"externalProviderToken\":\"string\",\"externalProviderType\":\"GOOGLE\",\"organizationName\":\"string\"}"

            headers = { 'content-type': "application/json" }

            conn.request("POST", "/uauth/auth/login/user", payload, headers)

            res = conn.getresponse()
            data = res.read()

            print(data.decode("utf-8"))
        - lang: JavaScript
          label: JavaScript
          source: |-
            const data = JSON.stringify({
              "username": "string",
              "password": "string",
              "deviceId": "string",
              "externalProviderToken": "string",
              "externalProviderType": "GOOGLE",
              "organizationName": "string"
            });

            const xhr = new XMLHttpRequest();
            xhr.withCredentials = true;

            xhr.addEventListener("readystatechange", function () {
              if (this.readyState === this.DONE) {
                console.log(this.responseText);
              }
            });

            xhr.open("POST", "https://api.synerise.com/uauth/auth/login/user");
            xhr.setRequestHeader("content-type", "application/json");

            xhr.send(data);
        - lang: Node.js
          label: Node.js
          source: |-
            const http = require("https");

            const options = {
              "method": "POST",
              "hostname": "api.synerise.com",
              "port": null,
              "path": "/uauth/auth/login/user",
              "headers": {
                "content-type": "application/json"
              }
            };

            const req = http.request(options, function (res) {
              const chunks = [];

              res.on("data", function (chunk) {
                chunks.push(chunk);
              });

              res.on("end", function () {
                const body = Buffer.concat(chunks);
                console.log(body.toString());
              });
            });

            req.write(JSON.stringify({
              username: 'string',
              password: 'string',
              deviceId: 'string',
              externalProviderToken: 'string',
              externalProviderType: 'GOOGLE',
              organizationName: 'string'
            }));
            req.end();
        - lang: PHP
          label: PHP
          source: |-
            <?php

            $request = new HttpRequest();
            $request->setUrl('https://api.synerise.com/uauth/auth/login/user');
            $request->setMethod(HTTP_METH_POST);

            $request->setHeaders([
              'content-type' => 'application/json'
            ]);

            $request->setBody('{"username":"string","password":"string","deviceId":"string","externalProviderToken":"string","externalProviderType":"GOOGLE","organizationName":"string"}');

            try {
              $response = $request->send();

              echo $response->getBody();
            } catch (HttpException $ex) {
              echo $ex;
            }
        - lang: Java
          label: Java
          source: |-
            HttpResponse<String> response = Unirest.post("https://api.synerise.com/uauth/auth/login/user")
              .header("content-type", "application/json")
              .body("{\"username\":\"string\",\"password\":\"string\",\"deviceId\":\"string\",\"externalProviderToken\":\"string\",\"externalProviderType\":\"GOOGLE\",\"organizationName\":\"string\"}")
              .asString();
servers:
  - description: Microsoft Azure EU
    url: https://api.synerise.com
  - description: Microsoft Azure USA
    url: https://api.azu.synerise.com
  - description: Google Cloud Platform
    url: https://api.geb.synerise.com
tags:
  - name: Authorization
```
