hsyogesh
11/08/2021, 9:19 AMAleksei Tirman [JB]
11/08/2021, 10:44 AMhsyogesh
11/08/2021, 10:47 AMsuspend fun ssoAuth(userName: String, password: String): HttpResponse {
val httpResponse: HttpResponse = <http://client.post|client.post> {
url("<https://ssgosghop.emc.com/NGSSOauthRest/service/v1/amisauth.json>")
body = TextContent(
text = "<?xml version='1.0' encoding='UTF-8' standalone='yes'?><user><username>$userName</username><password>$password</password><authmode>0</authmode></user>",
contentType = ContentType.Text.Plain
)
headers {
append("apikey", "l7xxf97e3b26235f4f7585256ba489e78d37")
}
}
/* token =
Json.parseToJsonElement(httpResponse.readText()).jsonObject["object"]?.jsonObject?.get("authResult")?.jsonObject?.get(
"token"
).toString()*/
return httpResponse
}
above code is to get token
suspend fun getVersion(token: String): VersionResponse? {
return try {
val response: VersionResponse? = client.get {
url("<https://cloudiq.emc.com/api/version>")
val session = "ngssosession=$token"
println("fafa session - $session")
headers {
append("Cookie", session)
append("content-type", "application/json; charset=UTF-8")
append("Accept", "*/*")
append("Accept-Charset", "UTF-8")
append("accept-encoding", "deflate, gzip, br, zstd")
}
}
response
} catch (exception: Exception) {
exception.printStackTrace()
null
}
}
Aleksei Tirman [JB]
11/08/2021, 11:06 AMcookie
function for sending data for a session instead of manually adding the Cookie
header:
cookie("ngssosession", token)
hsyogesh
11/08/2021, 11:44 AMhsyogesh
11/08/2021, 12:11 PMhsyogesh
11/08/2021, 12:11 PMhsyogesh
11/08/2021, 12:12 PMhsyogesh
11/08/2021, 12:42 PMAleksei Tirman [JB]
11/09/2021, 9:12 AM