// Login logs a given user into a target Skuid Platform site and returns a RestApi connection
// that can be used to make HTTP requests
Login logs a given user into a target Skuid Platform site and returns a RestApi connection
that can be used to make HTTP requests
// Login logs a given user into a target Skuid Platform site and returns a RestApi connection // that can be used to make HTTP requests
func Login(host, username, password, apiVersion, metadataServiceProxy, dataServiceProxy string, verbose bool) (api *RestApi, err error) {
	if apiVersion == "" {
		apiVersion = "2"
	}
	loginStart := time.Now()
	if verbose {
		fmt.Println(fmt.Sprintf("Logging in to Skuid Platform as user: %v\n%v", username, host))
		fmt.Println("API Version: " + apiVersion)
	}
	conn := RestConnection{
		Host:       host,
		Username:   username,
		Password:   password,
		APIVersion: apiVersion,
	}
	if metadataServiceProxy != "" {
		proxyURL, err := url.Parse(metadataServiceProxy)
		if err != nil {
			return nil, err
		}
		conn.MetadataServiceProxy = proxyURL
	}
	if dataServiceProxy != "" {
		proxyURL, err := url.Parse(dataServiceProxy)
		if err != nil {
			return nil, err
		}
		conn.DataServiceProxy = proxyURL
	}
	err = conn.Refresh()
	if err != nil {
		return nil, err
	}
	err = conn.GetJWT()
	if err != nil {
		return nil, err
	}
	api = &RestApi{
		Connection: &conn,
	}
	if verbose {
		fmt.Println(text.SuccessWithTime("Login Success", loginStart))
		fmt.Println("Access Token: " + conn.AccessToken)
	}
	return api, nil
}
func Login ( host , username , password , apiVersion , metadataServiceProxy , dataServiceProxy string , verbose bool ) ( api * RestApi , err error ) { if apiVersion == " " { apiVersion = " " } loginStart := time . Now ( ) if verbose { fmt . Println ( fmt . Sprintf ( " \n " , username , host ) ) fmt . Println ( " " + apiVersion ) } conn := RestConnection { Host : host , Username : username , Password : password , APIVersion : apiVersion , } if metadataServiceProxy != " " { proxyURL , err := url . Parse ( metadataServiceProxy ) if err != nil { return nil , err } conn . MetadataServiceProxy = proxyURL } if dataServiceProxy != " " { proxyURL , err := url . Parse ( dataServiceProxy ) if err != nil { return nil , err } conn . DataServiceProxy = proxyURL } err = conn . Refresh ( ) if err != nil { return nil , err } err = conn . GetJWT ( ) if err != nil { return nil , err } api = & RestApi { Connection : & conn , } if verbose { fmt . Println ( text . SuccessWithTime ( " " , loginStart ) ) fmt . Println ( " " + conn . AccessToken ) } return api , nil }
Login logs a given user into a target Skuid Platform site and returns a RestApi connection
that can be used to make HTTP requests
Login logs a given user into a target Skuid Platform site and returns a RestApi connection that can be used to make HTTP requests