Real-Time


Login SOA

Para realizar el login es necesario tener un usuario autorizado por Real-Time.

La respuesta obtenida, es decir el “auth_access_token” es el token que será utilizado en los próximos endpoints como Authorization. Este tiene una duración de validez especifica.

Petición HTTP POST

POST https://soa.real-time.cl/login_ws

                            
    curl -X POST "https://soa.real-time.cl/login_ws" \
        -H "Content-Type: application/json;" \
        -d '{"email":"YOUR_EMAIL_HERE","password":"YOUR_PASSWORD_HERE"}'
                            
                        
                            
        $url = 'https://soa.real-time.cl/login_ws';
        $data = array('email' => 'YOUR_EMAIL_HERE', 'password' => 'YOUR_PASSWORD_HERE');

        $options = array(
            'http' => array(
                'header'  => "Content-type: application/json\r\n",
                'method'  => 'POST',
                'content' => json_encode($data),
            ),
        );
        $context  = stream_context_create($options);
        $result = file_get_contents($url, false, $context);

        if ($result === FALSE) { /* Handle error */ }

        var_dump($result);

                            
                        
                            
    # Install the Python Requests library:
    # `pip install requests`

    import requests

    def send_request():
        # You may modify this method according to your needs.
        # POST https://soa.real-time.cl/login_ws

        try:
            response = requests.post(
                url="https://soa.real-time.cl/login_ws",
                headers={
                    "Content-Type": "application/json;",
                },
                data={
                    "email": "YOUR_EMAIL_HERE",
                    "password": "YOUR_PASSWORD_HERE",
                },
            )
            print('Response HTTP Status Code: {status_code}'.format(
                status_code=response.status_code))
            print('Response HTTP Response Body: {content}'.format(
                content=response.content))
        except requests.exceptions.RequestException:
            print('HTTP Request failed')

                            
                        
                            
        fetch('https://soa.real-time.cl/login_ws', {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json'
            },
            body: JSON.stringify({
                email: 'YOUR_EMAIL_HERE',
                password: 'YOUR_PASSWORD_HERE'
            })
        })
        .then(response => response.json())
        .then(data => console.log(data))
        .catch((error) => {
            console.error('Error:', error);
        });
    
                            
                        
                            
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;

public class Main {
    public static void main(String[] args) throws Exception {
        URL url = new URL("https://soa.real-time.cl/login_ws");
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        conn.setRequestMethod("POST");
        conn.setRequestProperty("Content-Type", "application/json; utf-8");
        conn.setDoOutput(true);

        String jsonInputString = "{\"email\": \"YOUR_EMAIL_HERE\", \"password\": \"YOUR_PASSWORD_HERE\"}";

        try(OutputStream os = conn.getOutputStream()) {
            byte[] input = jsonInputString.getBytes("utf-8");
            os.write(input, 0, input.length);			
        }

        int code = conn.getResponseCode();
        System.out.println(code);
    }
}
                            
                        

Asegurate de reemplazar YOUR_EMAIL_HERE y YOUR_PASSWORD_HERE con tus credenciales de la API.

Si la autenticación fue exitosa, la API responderá con el status HTTP 200 OK y en el body de la respuesta, obtendrás el auth_access_token y el status respectivamente.

Una respuesta exitosa a la operación de autenticación retorna un JSON con la siguiente estructura:

                        
{
    "auth_access_token":"YOUR_ACCESS_TOKEN_HERE",
    "status": true
}