Yes, we built GetAuthorizationToken method ourselves so you can compose the request however you need.
Basically, in order to get your token, you are just making another REST request to their authorization endpoint.
Example:
Method GetAuthorizationToken() As%Status
{
//Authenticate with Systemset tHttpResponse=##class(%Net.HttpResponse).%New()
set tHttpRequest = ##class(%Net.HttpRequest).%New()
set tHttpRequest.ContentType="application/x-www-form-urlencoded"//Get username and pwd out of Credential storeset objCred = ##class(Ens.Config.Credentials).%OpenId(..Adapter.Credentials)
//Insert the username and pwd (in your case may be "email" instead of "username")do tHttpRequest.InsertFormData("username",objCred.Username)
do tHttpRequest.InsertFormData("password",objCred.Password)
//add any other things the request may need//send auth requestset tURL=..AuthURLset tSC = ..Adapter.SendFormDataArray(.tHttpResponse,"POST",tHttpRequest,"","",tURL)
//Get response, were our credentials accepted?set tStatusCode = tHttpResponse.StatusCode
$$$TRACE("Authorization Status Code [" _ tStatusCode _ "]")
if tStatusCode = 200 {
set..tToken=tHttpResponse.access_token
Return$$$OK
} else {
Quit$$$ERROR("5001", "tStatusCode - can't auth with System")
}
}
}- Log in to post comments