Dear Kevin,
here's my code (please see below)
note itr_request is a tokenrequest object
note itr_response is a tokenresponse object
ioac_Client is a OAuth client
Microsoft says:
Authorization response
If the user consents to the permissions your app requested, the response will contain the authorization code in the code
parameter. Here is an example of a successful response to the previous request. Because the response_mode
parameter in the request was set to query
, the response is returned in the query string of the redirect URL.
GET https://localhost/myapp/?
code=M0ab92efe-b6fd-df08-87dc-2c6500a7f84d
&state=12345
I don't know how to grab that code for the token call
**********************************************************************************
ls_redirect = "https://localhost"
itr_Request.tokenlocation = "https://login.microsoftonline.com/<MY-Tenant>/oauth2/v2.0/authorize"
itr_Request.Method = "POST"
itr_Request.secureprotocol = 0
itr_Request.clientid = "<myclientid>"
itr_Request.clientsecret = "<MySecret>"
itr_Request.UserName = "myaccount@testme.eu"
itr_Request.Password = "testtttt"
itr_Request.scope = "Mail.Send"
itr_Request.granttype = "password"
itr_Request.AppendParam( "response_mode", "query" )
itr_Request.AppendParam( "response_type", "code" )
itr_Request.AppendParam( "redirect_uri", ls_Redirect )
ll_Return = ioac_Client.AccessToken( itr_Request, itr_Response )
If ll_Return = 1 and itr_Response.GetStatusCode () = 200 Then
ls_test = itr_Response.getstatustext()
ll_Return = itr_Response.GetBody(ls_Body)
If ll_Return = 1 Then
is_AccessToken = itr_Response.GetAccessToken()
End If
Else
ll_Return = itr_Response.GetTokenError(ls_type, ls_description, ls_uri, ls_state)
MessageBox( "AccessToken Failed", "Return :" + String ( ll_return ) + "~r~n" + ls_description )
End If