grails-oauth-scribe icon indicating copy to clipboard operation
grails-oauth-scribe copied to clipboard

Need a way to override the successUri/failureUri/callback specified in Config

Open aldrinm opened this issue 12 years ago • 2 comments

For the same provider, need a way to specify different callback uri, so that different links can return to different pages. Or at least have a way to pass a querystring parameter into the callback uri that is readable in the callback page.

aldrinm avatar Jul 07 '12 13:07 aldrinm

I have the same problem. I'm using the grails oauth plugin to connect to linkedin. I can't find how to make a call to the remote oauth service, and then go back to the calling page, when the calling page contains an identifier in the url.

Let me say that in more detail below.

I wish to create the following flow between urls: A => linkedin => B => A'

where:

  • A is a page without my linkedin profile photo, but specific to my user (its url is like /foo/bar/12458 where 12458 is my user id)
  • linkedin is my remote service, using the oauth protocol
  • B is my linkedin success/failure controller, which must redirect to A (including the correct user id)
  • A' is identical to A, but thanks to the linkedin credentials in the session, it also shows my linkedin profile photo.

I've hacked an ugly solution, by storing the user id in the session:

  • in controller A, I have set: session["user-id"] = user_id
  • in controller B, I can retrieve it and do the redirection: redirect(controller:"a", params: ['user_id': session["user-id"]])

This works, but I'm manually polluting the session with my user-specific callback url.

It would be good to have a way of building the redirect without first storing it in the session !

Looking around (see http://stackoverflow.com/questions/6463152/facebook-oauth-custom-callback-uri-parameters), it seems that the protocol would allow for that, either by inserting the information in the return uri, like I've asked for above, or by including another parameter ('state') to the linkedin call. How do I set that 'state' then?

Just in case it helps, here is the call I perform on the service:

def apiURL = "http://api.linkedin.com/v1/people/~:(id,first-name,last-name,picture-url)"
def linkedInAccessToken = getToken(session)
def postResult = oauthService.accessResource('linkedin', linkedInAccessToken, 'GET', apiURL)

igorrosenberg avatar Dec 04 '12 10:12 igorrosenberg

Hi There,

This is an interesting issue that I haven't yet run into. I will have to look at it in more detail when I have some time. State rings a bell, I think that the plugin allows that parameter - I'll have to check though.

If you come up with a good solution please feel free to issue a pull request!

Cheers, Antony

antony avatar Dec 16 '12 00:12 antony