How to encode redirect_uri for facebook login

I am trying to create a facebook login link and I only get errors in some cases. I am trying to specify the querystring parameter in the redirect_uri token so that I can redirect them back to a specific area of ​​my site after logging in. Here's what works and what doesn't work.

&redirect_uri=http://mydomain.com/login?returnUrl=returnUrl - works &redirect_uri=http://mydomain.com/login?returnurl=/return/url - does not work &redirect_uri=http%3a%2f%2fmyagentcheckin.com%2flogin%3freturnUrl%3d%2freturn%2furl - does not work

It seems that / in querystring is crashing. When I try, Facebook returns an error. Does anyone know about this?

+4
source share
4 answers

Instead of including the returnUrl parameter as part of your redirect_uri value, use the status parameter to store this data.

For instance,

https://graph.facebook.com/oauth/authorize?type=web_server&client_id= {appid} & redirect_uri = http://www.yoursite.com/oauth/handshake& state = / request / page

+5
source

I experienced something similar, especially with a few redirects as mentioned above.

My solution is to put returnUrl in a user session (or possibly a cookie), so I don't have to deal with double coding. For redirect_url just omit the request.

+1
source

Try using this API that integrates. This will save you from this problem.

No url encoding required.

Authentication Example

 Imports Branches.FBAPI ... Dim SI As New SessionInfo("[application_id]","applicaiton_secret") SI.AuthenticateUser("http://[my url]", New SessionInfo.PermissionsEnum(){SessionInfo.PermissionsEnum.email, SessionInfo.PermissionsEnum.read_stream})) 

Read the answer from the above URL from this page.

 Dim FSR = FS.ReadFacebooAuthResponse 
0
source

When I tried to do what you are doing, I got a callback with a redirect like this. http://mydomain.com/login?returnurl=%2Freturn%2Furl&code= ...

And I decode the value of "returnurl". Then it worked for me.

0
source

All Articles