Home > Blockchain >  How get # fragment values from the URL in Django
How get # fragment values from the URL in Django

Time:03-23

In my Django website, I want to redirect to an external website, authenticate on this external website and then the external website returns an API token that I want to save.

I have instructed the external website to redirect to 127.0.0.1:8000 (my home page) after I have successfully authenticated. When I'm redirected, I have a URL in this format:

http://127.0.0.1:8000/#access_token={token the external website generates}&token_type=Bearer&expires_in={expiry time}.

How can I get the values after the # in the URL? As I understand the values after the # is not sent back to the Django server.

CodePudding user response:

Yeah that is never sent to the server. What you could do is grab it with some JS, and submit it manually.

window.location.hash // gets you that value
  • Related