1. Mike Trainor
  2. PowerBuilder
  3. Tuesday, 26 September 2017 17:35 PM UTC

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.

Roland Smith Accepted Answer Pending Moderation
  1. Wednesday, 27 September 2017 02:19 AM UTC
  2. PowerBuilder
  3. # 1

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?

 

Comment
  1. Roland Smith
  2. Wednesday, 27 September 2017 02:22 AM UTC
Crap, I didn't read the posters name until after I posted my answer. Your Quickbooks access is still not complete. Someone at the conference gave a session on saving files to Azure blob storage and made use of my Bcrypt example.

  1. Helpful
  1. Mike Trainor
  2. Monday, 2 October 2017 19:18 PM UTC
Our Quickbooks interface is working like a charm (Oauth1). They (QB) are now talking Oauth2 and ADP and TSheets , as in time sheets, also are using OAuth2. Cheers, Mike



 

  1. Helpful
  1. Kevin Ridley
  2. Wednesday, 20 March 2019 11:59 AM UTC
Check out the OAuthClient object. Best bet is to create a service account (hopefully they have that) and get a client secret code. You use that to get an OAuth2 access token which should probably work the same as your OAuth1 token.
  1. Helpful
There are no comments made yet.
Daniel Vivier Accepted Answer Pending Moderation
  1. Thursday, 5 October 2017 22:03 PM UTC
  2. PowerBuilder
  3. # 2

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).

Comment
There are no comments made yet.
Ed Van Haren Accepted Answer Pending Moderation
  1. Wednesday, 28 March 2018 16:18 PM UTC
  2. PowerBuilder
  3. # 3

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 ))

Comment
There are no comments made yet.
Giuseppe moglia Accepted Answer Pending Moderation
  1. Tuesday, 19 March 2019 21:22 PM UTC
  2. PowerBuilder
  3. # 4

anyone has dropbox example?

 

Thanks

Comment
There are no comments made yet.
Armeen Mazda @Appeon Accepted Answer Pending Moderation
  1. Tuesday, 19 March 2019 22:25 PM UTC
  2. PowerBuilder
  3. # 5
Comment
There are no comments made yet.
Kevin Ridley Accepted Answer Pending Moderation
  1. Wednesday, 20 March 2019 12:02 PM UTC
  2. PowerBuilder
  3. # 6

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.

Comment
  1. Armeen Mazda @Appeon
  2. Wednesday, 20 March 2019 17:00 PM UTC
Please post your code sample to CodeXchange and then share the link to that when responding to Q&A. Thanks!
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.