E
E
ewerestr2021-11-04 14:17:51
C++ / C#
ewerestr, 2021-11-04 14:17:51

How to get full URL from HTTP request?

Good day! I'm trying to implement authorization on Yandex.Disk by authorization through a popup window. Yandex returns an access token using an HTTP request to the CallbackURL specified in the application settings or in the authorization request. To get it, I run the HttpListener class in my program and listen to the local host until the same request containing the token arrives. The scheme works, the request comes to the program. Yandex returns the token in the following form - "#token=qwertyuiop...", if you add this to the CallbackURL, you get something like this - " 127.0.0.1/callback#token=qwertyuiop...". Actually, the problem is that I can't get the part of the request after the '#' character, as well as the character itself. This situation confuses me. I've rummaged through all the possible fields of the HttpListener class, but none of them are anything like does not contain. Has anyone encountered a similar one?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
ewerestr, 2021-11-05
@ewerestr

Issue resolved. The part of the request behind the pound symbol is a hash and only the client side sees it, in this case the popup window. Wrote a simple js script. The first time my listener is contacted, it sends this script in response, as a result, the browser replaces the hash character in the request with a question mark, after which the hash becomes the request parameters, then it is re-sent to my listener and I can already get the parameters from the request. The question is closed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question