Research Log of Web Science Students

Computer Science is not simply programming

UrlRewriting Problem

leave a comment »

I need to add an extra custom parameter to my oauth callback url so that my controllers know which provider to use.

http://hard-wire.appspot.com/callback?provider=googledocs....etc etc

But this creates problems with

1. my controller because doing this…

String providerRequested = request.getParameter("provider");

to the url above returns:

googledocs?oauth_token_secret=[masked]

when it should only return googledocs not the extra gibberish tailing it.

I wonder if I should use the addExtraParameter in the OAuthParameters class instead of specifying the callback url to be “http://hard-wire.appspot.com/callback?provider=googledocs”?

UPDATE 1: the abstract factory method is at fault. It’s not returning a concrete implementation first at

if ("googledocs".equals(providerRequested))

Obviously because googledocs is not equal to the url above. I thought it might work by doing this instead:

if ("googledocs".contains(providerRequested))

but apparently the input to method contains should be a type of charSequence.

UPDATE 2: Progress! I tried doing this but to no avail:

if (providerRequested.contains("googledocs"))

Except that I get an

OAuthException

Will work on using addExtraParameter to the oauthParameters.

UPDATE 3: I didn’t want to dive into figuring out addExtraParameter,
instead I tried to remove the “provider=googledocs” in the result.queryString() that the oauthParameters use.

RESULT: Didn’t work out.

UPDATE: Went back to my original problem by adding a “?” to the callback url which is

//old callback
http://hard-wire.appspot.com/callback?provider=googledocs

//new callback
http://hard-wire.appspot.com/callback?provider=googledocs?

Result: Didn’t work out too, when I get the parameter provider it returns this:

googledocs??oauth_token_secret=[masked]

UPDATE: I realized that the url above shouldn’t be ?? but be & instead.

provider=googledocs&oauth_token_secret=[masked]

What this means is that the queryString should be

oauth_token_secret=[masked]etc...

Result: Ok for some reason the OAuthHelper does not parse the queryString despite my best efforts to give it the right queryString.

Advertisements

Written by Jose Asuncion

October 3, 2009 at 12:38 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: