Authorization on the site via mail.ru
Good time of day!
On the site, I implement getting an OAuth access token from mail.ru and I came across the problem that after authorization and confirmation of rights, this mail.ru redirects the user to its own url "http://connect.mail.ru/oauth/success.html#expires_in=00000&refresh_token=0000&access_token=0000&token_type=bearer&x_mailru_vid=0000", although I pass redirect_uri when requesting.
I test from a local computer at the ip address 192.168..... and there is I suspect that this is the whole point, but if anyone has encountered such a problem, please tell me how to solve it!
2 answers
Yes, this is most likely due to the fact that testing is happening from the local machine. On the Internet, they write such methods:
https://connect.mail.ru/oauth/authorize?
client_id=идентификатор вашего сайта&
response_type=token&
redirect_uri=адрес принимающей страницы на вашем сайте
In the value of the redirect_uri parameter, pass the address of the page to which the user will be redirected after authorization. This page must be located on your site's domain.
Code - use it if you need access to the API and user data only from the server side of your site
Token - use it if you need access to the API only from JavaScript, for example, if you have a web application running entirely inside the user's browser
Code_and_token - if you need access to the API from both the server side of the site and JavaScript, use this option
** If you specified response_type=token** After authorization, the browser will be redirected to the following address:
http://example.com/oauth/receiver#
refresh_token=b45529ac9bf6b32be761975c043ef9e3&
access_token=b6442ed12223a7d0b459916b8ea03ce5&
token_type=bearer
Mail.ru they can't make several fields for the site URL, for example, so that you can put one production and another localhost read here https://my.mail.ru/community/myplatform/7DE49B6937BC56F6.html That is, the redirect must match the site address. And you can't register an application on a localhost either, for example, on http://localhost:5000 I didn't succeed, so I have to create an application with a normal address, then change it to a localhost. In short it is complete obscurantism in the whole normal Internet is made so that you can add several URLs, but this is mailru, a complete village.