A
A
Anton Gribov2015-05-23 18:01:47
.NET
Anton Gribov, 2015-05-23 18:01:47

How to get text after # character when receiving request via HttpListener?

I'm sending an authorization request through a third party library to dropbox. Upon clicking a button in the browser, dropbox requests a redirect_uri that my app is listening on. The format is as follows

[REDIRECT_URI]#access_token=ABCDEFG&token_type=bearer&uid=12345&state=[STATE]

I'm using the HttpListener class, but after receiving a request, the httpListener.Request.Url property contains the address before the hash.
I tried it, it always does this - shows the address up to the hash mark and up to the question mark too, if it is used. Question: how to deal with it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Tsiren Naimanov, 2015-05-23
@ImmortalCAT

char[] separators = { '=', '&' };
string[] responseContent = responseString.Split(separators);
string accessToken = responseContent[1];
int userId = Int32.Parse(responseContent[5]);
MessageDialog dialogSuccess = new MessageDialog("access_token = "+accessToken+ "\nuser_id = "+userId);
dialogSuccess.ShowAsync();

Taken from Habr example from VK API habrahabr.ru/post/201074

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question