login()

The login method returns a token, access_token, that will be used for authentication with other method calls. To successfully call this method you will need a username and password- these are found in your API key file, which is available from the Dashboard (see steps 2 and 3 of of the quickstart for more info).

Parameters
Parameter Required Data type Pattern Notes
username Yes String

AbC123-9999

The username obtained from the dashboard API key file.
password Yes String

4sb62fh6w4h7w34g

The password obtained from the dashboard API key file.

 


Response Example
{ "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmcmVzaCI6dHJ1ZSwianRpIjoiZjhmNDlmMjUtNTQ4OS00NmRjLTkyOWUtZTU2Y2QxOGZhNzRlIiwidXNlcl9jbGFpbXMiOnt9LCJuYmYiOjE0NzQ0NzQ3OTEsImlhdCI6MTQ3NDQ3NDc5MSwiaWRlbnRpdHkiOiJ0ZXN0IiwiZXhwIjoxNDc0NDc1NjkxLCJ0eXBlIjoiYWNjZXNzIn0.vCy0Sec61i9prcGIRRCbG8e9NV6_wFH2ICFgUGCLKpc",
  "refresh_token": "CJ0eXBlIjoinRpIjoiZjhmNYWNjZXNzI1NiIsiOiJ0ZXN0IiwiZXhzyJhbInR5cCI6IkpXVCJ9.eyJmcmVzaCI6dHJ1ZSwiaDlmMjUtNTQ4OS00NmRjLTkyOWUtZTU2Y2QxOGZhNzRlIiwidXNlcl9jbGFpbXMiOnt9LCJuYmYiOjE0n0.vCy0Sec61i9prcGIRRCbG8e9NV6_wFH2ICFgUGCLKpcNzQ0NzQ3OTEsImlhdCI6MTQ3NDQ3NDc5MSwiaWRlbnRpdHkGciOiJIUwIjoxNDc0NDc1NjkxLI",
  "msg": "Success"}
Code Snippet 

                    # The following shell script will use cURL to call login
# and return the json response.

curl -d '{"username":"**your-username**", "password":"**your-password**"}' \ 
-H "response-content-type: json" \ 
-X POST https://**your-full-implementation-url**/login
                
                    // The following Java code will make a login call
// and print the json response.

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.Reader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
import java.util. *;

class GalileoAPICall
{
    public static void main(String[] args) {
        try {
            Map<String,Object> params = new LinkedHashMap<>();
           params.put("username", "**your-username**");
           params.put("password", "**your-password**");
            StringBuilder postData = new StringBuilder();
            for (Map.Entry<String,Object> param : params.entrySet()) {
                if (postData.length() != 0) postData.append('&');
                postData.append(URLEncoder.encode(param.getKey(), "UTF-8"));
                postData.append('=');
                postData.append(URLEncoder.encode(String.valueOf(param.getValue()), "UTF-8"));
            }
            byte[] postDataBytes = postData.toString().getBytes("UTF-8");

            URL url = new URL("https://**your-full-implementation-url**/login");

            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            conn.setRequestMethod("POST");
            conn.setRequestProperty("response-content-type", "json");
            conn.setRequestProperty("Content-Length", String.valueOf(postDataBytes.length));
            conn.setDoOutput(true);
            conn.getOutputStream().write(postDataBytes);

            String xmlOutput;

            Reader in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
            for (int c; (c = in.read()) >= 0;) {
                System.out.print((char)c);
            }
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
                
                    # The following Python code will call login
# and print the json response.

import requests
headers = {'response-content-type': 'json'}
payload = {'username': '**your-username**', 'password': '**your-password**'}
r = requests.post(url='https://**your-full-implementation-url**/login', data=payload, headers=headers)
try:
    print(r.json())
except:
    print(r.status_code)
                
                    // The following PHP code will make a login call
// and prints the json response.

$endpoint = 'https://**your-full-implementation-url**/login';
$params = array('username'=>'**your-username**', 'password'=>'**your-password**');

$curl = curl_init();
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $params);
curl_setopt($curl, CURLOPT_URL, $endpoint);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('response-content-type: json'));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

$result = curl_exec($curl);
curl_close($curl);
$json = new json_decode($result, true);
print_r($json);

                
                    // The following C# code will make a login call
// and print the json response.

using System;using System.IO;
using System.Net;
using System.Text;

byte[] data = Encoding.ASCII.GetBytes(
    "username=**your-username**&password=**your-password**");
WebRequest request = WebRequest.Create("https://**your-full-implementation-url**/login");
request.Method = "POST"\;
request.ContentLength = data.Length;
request.Headers.Add("response-content-type", "json");
using (Stream stream = request.GetRequestStream())
{
    stream.Write(data, 0, data.Length);
}
string responseContent = null;
using (WebResponse response = request.GetResponse())
{
    using (Stream stream = response.GetResponseStream())
    {
        using (StreamReader sr = new StreamReader(stream))
        {
            responseContent = sr.ReadToEnd();
        }
    }
}
Console.WriteLine(responseContent);
                
                    # The following Ruby code will make a login call
# and print the json response.

require 'uri'
require 'net/http'

uri = URI("https://**your-full-implementation-url**/login")
https = Net::HTTP.new(uri.host, uri.port)
https.use_ssl = true
request = Net::HTTP::Post.new(uri.path)
request['response-content-type'] = 'json'
request.body = {username: '**your-username**', password: '**your-password**'}.to_json
response = https.request(request)
puts response