Login   Register  
PHP Classes
elePHPant
Icontem

redirect_uri with $_SERVER['REQUEST_URI']

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us

      PHP OAuth API  >  All threads  >  redirect_uri with $_SERVER['REQUEST_URI']  >  (Un) Subscribe thread alerts  
Subject:redirect_uri with $_SERVER['REQUEST_URI']
Summary:redirect_uri with $_SERVER['REQUEST_URI']
Messages:4
Author:Markus S.
Date:2013-05-29 13:48:46
Update:2013-05-31 15:37:23
 

  1. redirect_uri with $_SERVER['REQUEST_URI']   Reply   Report abuse  
Picture of Markus S.
Markus S.
2013-05-29 13:48:46
I got the following error

OAuthException: Error validating verification code. Please make sure your redirect_uri is identical to the one you used in the OAuth dialog request.

this happens because I used the following redirect URI.

$client->redirect_uri = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];

when using a static redirect uri, or one which does not depend on the current URL of the script it works like a charm.


the problem is, that the oauth client redirect to itself and appends some parameter which slip into the redirect_uri when defined like above.

How to work arround this problem? could the oauth_client_class define a helper method which would strip all oauth related params from a given url, so one could define a redirect_uri like 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; ?

  2. Re: redirect_uri with $_SERVER['REQUEST_URI']   Reply   Report abuse  
Picture of Manuel Lemos
Manuel Lemos
2013-05-30 00:38:34 - In reply to message 1 from Markus S.
You should use the script name instead of $_SERVER['REQUEST_URI'] just like in the examples.

  3. Re: redirect_uri with $_SERVER['REQUEST_URI']   Reply   Report abuse  
Picture of Markus S.
Markus S.
2013-05-31 06:48:59 - In reply to message 2 from Manuel Lemos
the expression vom the example doesn't work for me, because the oauth login is behind a url which already contains a parameter

www.example.com/login?oauth=Facebook

  4. Re: redirect_uri with $_SERVER['REQUEST_URI']   Reply   Report abuse  
Picture of Manuel Lemos
Manuel Lemos
2013-05-31 15:37:23 - In reply to message 3 from Markus S.
You should use whatever works for you, just not $_SERVER['REQUEST_URI'] because it will include request parameters that will be duplicated by the class when it appends the parameters needed by the OAuth protocol.