S
S
Sergey Krivochenko2013-11-13 11:53:21
PHP
Sergey Krivochenko, 2013-11-13 11:53:21

Redirect_uri with parameters when using OAuth authorization

Good day to all. I am implementing authorization into the site through VKontakte. Task: to make it so that when you log in from any page of the site, if successful, the same page opens again.

Example: page address http://site.ru/articles?category=1&id=8

When generating a page, I create a link:

Авторизация через ВКонтакте

As a result, when the user clicks on the link and then logs in to the Vkontakte website, he is redirected to the page http://site.ru/articles?category=1&code=8d61a70a2be1d7d8a8

How to redirect to http://site.ru/articles?category=1&id=8&code=8d61a70a2be1d7d8a8

Answer the question

In order to leave comments, you need to log in

8 answer(s)
A
Alexey Lizurchik, 2013-11-13
@krivochenko

Encode your redirect_uri parameters, at least with http_build_query, so that & is %26 instead

R
Rpsl, 2013-11-13
@Rpsl

The value of the redirect_uri parameter makes sense to encode

A
ASPAnt, 2013-11-13
@ASPAnt

Try swapping the redirect_uri and response_type parameters in the authorization link

S
Sergey Krivochenko, 2013-11-13
@krivochenko

Well, there seems to be only one way out. You will have to replace the ampersand with %26, and after authorization - back %26 with an ampersand and make another redirect.

P
phpdude, 2013-11-13
@phpdude

url escaping will help you. if php - php.net/urlencode

R
RSV, 2013-11-14
@RSV

Alternatively, in the user's session, always store the last page they opened. Every time a user opens a page, check the session and ref data. If the ref is "VKontakte", then redirect the user to the address stored in the session.

A
azShoo, 2014-11-19
@azShoo

To solve applied problems, it is better to use Python. Simpler, more concise, a billion libraries for solving intermediate problems.
If we talk exclusively about Java vs C #, then there is essentially no difference.

W
wrench10x12, 2014-11-19
@wrench10x12

>tasks cost more than the simplest
ones

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question