OAuth v2 Authentication Scheme

824 views
Skip to first unread message

mcol...@fmsworks.com

unread,
Mar 17, 2015, 11:47:19 AM3/17/15
to suppor...@runmyprocess.com
Hi,

I'm trying to integrate RMP with Wrike. Wrike uses OAuth2 authentication scheme, using an access token that must be refreshed every hour. I've been able to setup a connector in RMP to interact with Wrike's API, but so far I've had to manually refresh the access token, and paste the new access token into the Access token field.

So far I haven't seen much documentation on how to automatically refresh the access token, but I know there is an option somehow to do this through a composite API. I also saw that two new Freemarker methods were recently released: P_get_oauth2_token(service) and P_save_oauth2_token(service, token)

Whenever a Wrike API method fails due to an expired access token, I need to setup the Wrike provider in RMP to automatically refresh the token and to then retry the same API method. Can somebody explain in detail, possibly with screenshots, how to set this up using the composite api, the new Freemarker methods, or whatever else must be used?

Thanks and best regards!

Pray Desai

unread,
Mar 18, 2015, 3:41:21 PM3/18/15
to suppor...@runmyprocess.com
Hi,

We have an example now in documentation with Dropbox OAuth2 to automactically refresh token using Composite API and new freemarker methods. 

Here is the link :


Can you refer to it and make a similar one for Wrike? Feel free to contact us if you had any issues.

Regards,
Pray Desai,
Fujitsu RunMyProcess.


--
Fujitsu - RunMyProcess
---
You received this message because you are subscribed to the Google Groups "Fujitsu RunMyProcess Developer Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to supportforum...@runmyprocess.com.
To post to this group, send email to suppor...@runmyprocess.com.
Visit this group at http://groups.google.com/a/runmyprocess.com/group/supportforum/.
To view this discussion on the web visit https://groups.google.com/a/runmyprocess.com/d/msgid/supportforum/2b251048-593a-4594-91a0-34b6e1a4133e%40runmyprocess.com.
For more options, visit https://groups.google.com/a/runmyprocess.com/d/optout.

mcol...@fmsworks.com

unread,
Apr 6, 2015, 4:19:22 PM4/6/15
to suppor...@runmyprocess.com
Hi Pray,

I've worked with the registration part of the Oauth2 tutorial for Wrike off and on for the last two weeks. I've finally reached a snag I can't figure out.

I copied the web interfaces and the CAPI described in the tutorial for Dropbox, and customized them for Wrike as best as I could. When I tested the web interface with the "Authorize" button, it successfully redirected me to the Wrike login page where I allowed it to access my data. It then successfully redirected me to the OAuth Token Authorize Callback web interface. This is the part it seems to break down. I keep getting an error pop that just says {"error":""} which indicates the javascript or CAPI isn't executing properly, but I'm not sure how.

Any idea what would be causing the problem? Let me know if there are any specific screenshots that would be helpful for you.

Thanks and best regards,
Michael Coleman

Pray Desai

unread,
Apr 6, 2015, 9:19:19 PM4/6/15
to suppor...@runmyprocess.com, mcol...@fmsworks.com

Hi Michael,

You can check error details in browser console (press F12, go to Network tab, Path, check request and response headers of a path in red font). Let us know error details if you couldnot solve yourself.


Regards,
Pray Desai,
Fujitsu RunMyProcess.

mcol...@fmsworks.com

unread,
Apr 7, 2015, 9:23:27 AM4/7/15
to suppor...@runmyprocess.com, mcol...@fmsworks.com
Hi Pray,

these are the errors that are showing up for me:

INFO: Unable to read a header
java.io.IOException: Parameter or extension has no name. Please check your value
at Unknown.Pl(0.js@20)
at Unknown.Sl(0.js@19)
at Unknown.zkd(0.js@20)
at Unknown.CId(0.js@217)
at Unknown.QId(0.js@4034)
at Unknown.yId(0.js@62)
at Unknown.PId(0.js@23)
at Unknown.cKd(0.js@893)
at Unknown.KHd(0.js@60)
at Unknown.MHd(0.js@77)
at Unknown.PHd(0.js@69)
at Unknown.zA(0.js@158)
at Unknown.RA(0.js@11404)
at Unknown.eval(0.js@65)
at Unknown.En(0.js@29)
at Unknown.Hn(0.js@57)
at Unknown.eval(0.js@45)
at Unknown.nrWrapper(https://live.runmyprocess.com/live/118401423585136914/appli/179354?P_mode=T…e=J7bsDNXRUycNHazJuWFqCo5tRZnR4fARHlj5aw6KnaVI97Y4eDAA6Wo96xciH4CH-N@12945)
https://live.runmyprocess.com/live/118401423585136914/host/116791/service/173466?P_mode=TEST&P_version= Failed to load resource: the server responded with a status of 500 (Internal Server Error)

mcol...@fmsworks.com

unread,
Apr 7, 2015, 9:32:26 AM4/7/15
to suppor...@runmyprocess.com, mcol...@fmsworks.com
I've also noticed some errors in the tutorial.

The following image shows how to setup a connector with a variable that inputs the current access token into the "Access token" field: http://docs.runmyprocess.com/images/Integration_Guide/OAuth2/Dropbox/oauth2_dropbox_provider.png

There are a couple of problems with this. For one, the image shows a mismatched parentheses: "${P_get_oauth_token('wirke').access_token)}". Also in the text below, it claims it is using a method called "P_get_oauth2_token()" which is a different method. Can you please clarify the correct way to setup this variable/method?

Pray Desai

unread,
Apr 7, 2015, 1:56:52 PM4/7/15
to suppor...@runmyprocess.com, mcol...@fmsworks.com

Thanks Michael for reporting the bugs, I have forwarded them to the product team. 

Can you remove the extra closing round bracket ) in the Access token field in C.API and use P_get_oauth2_token()  instead of P_get_oauth_token(). Then launch test of your CAPI and see if it is success.

Regards,
Pray Desai,
Fujitsu RunMyProcess.

mcol...@fmsworks.com

unread,
Apr 7, 2015, 5:06:21 PM4/7/15
to suppor...@runmyprocess.com, mcol...@fmsworks.com
HI Pray,

I've been scouring the OAuth Token Registration Composite API I created to register a new access token for the Wrike API, which is nearly copied verbatim from your example on doing this with Dropbox. The steps before the CAPI is triggered work fine, I get the access_code just fine, but something crashes when I try to exchange the access_code for an access_token in this last part using the CAPI.

How does the "trigger" javascript function work, I couldn't find any documentation on it. Currently the CAPI is triggered from the web interface with javascript using the line:
id_wrike_oauth_token.trigger(registration_parameters,{},registration_success,registration_failure);

What are the parameters for the trigger method?

Thanks,
Michael Coleman

Pray Desai

unread,
Apr 7, 2015, 5:17:50 PM4/7/15
to suppor...@runmyprocess.com, mcol...@fmsworks.com
Hi Michael,

Inorder to debug the crash, just launch test of the CAPI by passing variable code with a hard-coded value and see its result.


Regarding parameters for trigger method in your CAPI for OAuth, as mentioned in OAuth Dropbox tutorial, 

you need to write a script that passes code as input variable to the CAPI :

1
2
3
4
5
6
7
8
function registration_success(result) {
}
function registration_failure(error) {
    alert( JSON.stringify(error));
}
var registration_parameters = {};
registration_parameters.code = RMPApplication.getVariable('code');
id_dropbox_oauth_token.trigger(registration_parameters,{},registration_success,registration_failure);

Inline image 2
Regarding "trigger" CAPI by javascript, you can find its documentation here :

http://docs.runmyprocess.com/Developer_Guide/Composite_API/Composite_API_Example

Check the topic "Second Method"
Inline image 1

Regards,
Pray Desai,
Fujitsu RunMyProcess.

--
Fujitsu - RunMyProcess
---
You received this message because you are subscribed to the Google Groups "Fujitsu RunMyProcess Developer Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to supportforum...@runmyprocess.com.
To post to this group, send email to suppor...@runmyprocess.com.
Visit this group at http://groups.google.com/a/runmyprocess.com/group/supportforum/.

mcol...@fmsworks.com

unread,
Apr 8, 2015, 1:45:00 PM4/8/15
to suppor...@runmyprocess.com, mcol...@fmsworks.com
Hey Pray,

in the javascript that passes the value for code into the triggered CAPI, I assigned a hardcoded value to "registration_parameters.code" and still got the same nondescript error.

The page you linked to answered some questions, but didn't have the level of documentation I want. I was looking for more something like the documentation on this page: http://docs.runmyprocess.com/API_Reference/FM/Utilities.html

I'd like to see each parameter clearly spelled out, what type of data is expected for each, and what each parameter is used for. From the previous link you sent me, I can assume the first parameter is a JSON object that matches the input field for the CAPI. I am guessing the third and fourth parameter are names of success and failure functions for if the CAPI succeeds or fails, but what will determine if the triggered CAPI succeeds or fails? I see for the second field you pass an empty JSON object called options. What types of options are possible to be passed into it, and what do the options do?

How can I differentiate if the error is in the CAPI, or if the error is in the connector called by the CAPI?

Thanks,
Michael Coleman

mcol...@fmsworks.com

unread,
Apr 8, 2015, 1:56:47 PM4/8/15
to suppor...@runmyprocess.com, mcol...@fmsworks.com
Hey Pray,

so I just went back to my connector and realized it was still set for "http" as opposed to "https", so I'm sure this was causing a problem. Anyway, I'm still getting an error, which is a bit more informative this time:

{"error":"Error while processing ${P_json_put({}, 'result',result,true)}\nExpression result is undefined on line 1, column 27 in temp."}


Any idea what that means?

Thanks,
Michael Coleman

mcol...@fmsworks.com

unread,
Apr 8, 2015, 3:11:47 PM4/8/15
to suppor...@runmyprocess.com, mcol...@fmsworks.com
Hey Pray,

so I looked in my OAuth2 settings and it looks like it actually saved something despite giving me that error.

On another note, are the RMP servers having issues today? Everytime I try to open RMP or do anything in it, it will only half load some things, or not load at all.

Thanks!

Pray Desai

unread,
Apr 8, 2015, 3:26:51 PM4/8/15
to suppor...@runmyprocess.com, Michael Coleman
Yes, we have encountered slowness in our platform and our dev team will try to fix this global issue asap. We will keep you updated.

Regards,
Pray Desai,
Fujitsu RunMyProcess.

--
Fujitsu - RunMyProcess
---
You received this message because you are subscribed to the Google Groups "Fujitsu RunMyProcess Developer Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to supportforum...@runmyprocess.com.
To post to this group, send email to suppor...@runmyprocess.com.
Visit this group at http://groups.google.com/a/runmyprocess.com/group/supportforum/.

Pray Desai

unread,
Apr 8, 2015, 7:01:21 PM4/8/15
to suppor...@runmyprocess.com, Michael Coleman
Hi Michael,

The performance issue is fixed, Platform is up and back to normal. Sorry for the inconvenience caused.


Regards,
Pray Desai,
Fujitsu RunMyProcess.

mcol...@fmsworks.com

unread,
Apr 9, 2015, 4:08:36 PM4/9/15
to suppor...@runmyprocess.com, mcol...@fmsworks.com
Hey Pray,

I've been able to generate and store an access token, but it still doesn't seem to be automatically refreshing the access token. I created a CAPI to refresh the access token, but how can I know if the CAPI is even being called? I keep getting errors that the access token is invalid unless I go through the process of registering and storing an access token again.

Because there are so many obvious errors in the tutorial, it is hard for me to know where the unobvious errors may be. Can you help me figure out how to automatically refresh the access token?

Thanks,
Michael Coleman

Michael Coleman

unread,
Apr 10, 2015, 10:49:57 AM4/10/15
to suppor...@runmyprocess.com
Hey Pray,

here are some screenshots of how I set up my CAPI to automatically refresh my access token, they almost match the images of the tutorial for this part exactly.  Maybe you'll be able to spot what's wrong with what I'm doing.

Thanks,
Michael Coleman
RMP_refresh_token_1.JPG
RMP_refresh_token_2.JPG
RMP_refresh_token_3.JPG
RMP_refresh_token_4.JPG
RMP_refresh_token_5.JPG
RMP_refresh_token_6.JPG
RMP_refresh_token_7.JPG
RMP_refresh_token_8.JPG
RMP_refresh_token_9.JPG

mcol...@fmsworks.com

unread,
Apr 13, 2015, 9:52:23 AM4/13/15
to suppor...@runmyprocess.com, mcol...@fmsworks.com
Hey Pray,

still haven't heard back from you. Did you get a chance yet to look over those screenshots I sent you? If I manually launch the CAPI that refreshes my access token, then my access token is successfully refreshed. But if I use a connector I made for the Wrike API and the access token has expired, I just get errors saying the access token is invalid without it being automatically refreshed.

Any tips you may have would really be appreciated.

Michael Coleman

unread,
Apr 15, 2015, 12:58:55 PM4/15/15
to suppor...@runmyprocess.com
Since the functionality for automatically triggering the Refresh Token Capi does not seem to be working currently, I am attempting to manually include this functionality in my process.

After an API call is made, an XOR split checks to see if the result came back with an unauthorized token.  If not, then the process continues as normal, but if it does have an error, then it leads it back through a connector that refreshes the token, and with a back loop, attempts the same API call again.

I've run into a few hitches with this, and I'm unsure how to debug it.  Can you show me an example process with this kind of functionality?
Reply all
Reply to author
Forward
0 new messages