Page 1 of 1

oAuth 2.0 Restful Web Service

Posted: Wed Jun 16, 2021 9:27 pm
by byron.hopp
Is it possible to access a WebService using oAuth 2.0 from fivewin using CreateObject( "MSXML2.XmlHttp" ), I have been connecting with Carbonite using what seems to be a similar technique. I am attempting to access On-Site.com using their API's. There is some code to generate a Key and I believe this key is good for quite a while, whereas the Carbonite key needed to be generated every hour.

Sample code:
oHttp := CreateObject( "MSXML2.XmlHttp" )
hLogin["email" ] := "bhopp@matrixcomputer.com"
hLogin["password"] := "MyPassword"
cLogin := hb_JsonEncode( hLogin )

oHttp:Open( "POST","https:" + "/" + "/" + "api.carbonite.com:443/api/auth/login",.f. )
oHttp:SetRequestHeader( "Content-Type", "text/json" )
oHttp:Send( cLogin )

If oHttp:status == 200
cResponse := oHttp:ResponseText()
Logit( Mcs_AppPath() + "Request.txt",cResponse )
Else
MsgStop( "Status:" + oHttp:statusText,"Request Failed" )
Endif

Re: oAuth 2.0 Restful Web Service

Posted: Thu Jun 17, 2021 11:08 am
by Antonio Linares
Dear Byron,

what result do you get ?

Re: oAuth 2.0 Restful Web Service

Posted: Thu Jun 17, 2021 4:29 pm
by byron.hopp
Antonio,

This works Great, I guess I am going to try it, but I saw somebody posted using oAuth 2.0 and they utilized curl, which I am not familiar with, so I was hoping this would work. I have used this technique with Authorize.net as well. For each request the API describes what the result will look like.

I downloaded the oAuth specs and it's not a pretty read.

Thanks,

Byron ..