Getting Oauth 1,0 to work for was no small task. We no sooner got it working and along comes Oauth2.
Therefore we are hoping that someone can shed some light on this with working code.
Getting Oauth 1,0 to work for was no small task. We no sooner got it working and along comes Oauth2.
Therefore we are hoping that someone can shed some light on this with working code.
I have code for OAuth2 to access MS Dynamics using a service account and Azure. It was in my Elevate presentation but I can't find it posted anywhere. I'll try to dig it up.
Bruce has posted some code samples up on CodeXchange: https://community.appeon.com/index.php/codeexchange/powerbuilder/43-rest-demo-app-for-powerbuilder-2017-r2-and-r3-new-features#41
Also, he did a good tech article on this: https://community.appeon.com/index.php/articles-blogs/tutorials-articles/2-powerbuilder/204-oauth-new-feature-in-powerbuilder-2017-r3
anyone has dropbox example?
Thanks
I have started to use R2 and I get an OAuth token and tried to simply pass it in to the REST calls and it seems to work for me. These are internal calls to REST APIs that we have written. I am surprised it worked so easily (just be adding the setrequestheader). I didn't think this was going to be supported until R3. Call me a happy camper :)
For the new RESTClient I simply add a request header with the token and it works
RESTClient rest
rest = create RESTClient
rest.setrequestheader("Authorization", "Bearer " + is_token )
ll_rc = rest.Retrieve( dw_1, "https://xxxxx/List?Product=ASSESS")
To pass a PDF with other data to a REST call, I have done the following:
string ls_file, jsondata
blob lblob_pdf
int li_rc
Long ll_rc, ll_stat
httpclient http
ls_file = "C:\test.pdf"
JSONParser json
json = create JSONParser
ll_rc = f_file_to_blob(ls_file , ref lblob_pdf) //Converts file to blob
jsondata = '{"Access":"A", "Archive":"N","Product":"ASSESS"}' // data I need to pass to REST API
http = create httpclient
string ls_BOUNDARY
ls_BOUNDARY = "$$$Boundary$$$" // use or build a string that is not part of the other content!
// build the content
blob lblob_data
lblob_data = blob ("--" + ls_BOUNDARY + "~r~n" + &
'Content-Disposition: form-data; name="dockey"' + &
"~r~nContent-Type: " + "application/json;charset=UTF-8" + &
"~r~n~r~n" + jsondata + "~r~n", EncodingUTF8!)
lblob_data = lblob_data + blob ("--" + ls_BOUNDARY + "~r~n" + &
'Content-Disposition: form-data; name="docfile"; filename="' + 'Test' + '"' + &
"~r~nContent-Type: " + "application/octet-stream" + "~r~n~r~n", EncodingUTF8!) + &
lblob_pdf + blob ("~r~n--" + ls_BOUNDARY + "--~r~n", EncodingUTF8!)
http.setrequestheader( "Content-Type", "multipart/form-data; boundary=" + ls_BOUNDARY)
http.setrequestheader("Authorization", "Bearer " + is_write_token )
li_rc = http.sendrequest( 'POST', 'https://api.systest.worksafebc.com/v1/Correspondence_int/Upload', lblob_data)
ll_stat = http.GetResponseStatusCode()
MessageBox("Stat", String(ll_stat ))
I got OAuth2 working for sending emails via Gmail, but I have to tell you it's somewhat flaky. Don't know whether that's my code or Gmail. So I'm not sure there'd be a value in posting my code (nor, I'm afraid, do I have time right now to separate it out well enough to do so).
Different providers have different requirements. I have an example of how to post messages to Twitter:
http://www.topwizprogramming.com/freecode_twitter.html
There are people have have been able to connect to the Azure file system and Quickbooks online.
What service do you need to work with and what do you want to do with it?