Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to authenticate token from a regular view #273

Closed
juancresc opened this issue Jul 15, 2020 · 3 comments
Closed

How to authenticate token from a regular view #273

juancresc opened this issue Jul 15, 2020 · 3 comments

Comments

@juancresc
Copy link

I want the user to be able to download a PDF using easy_pdf
which has a :
from easy_pdf.views import PDFTemplateView

How can I do to validate the session from the obtained token in my view?

@Andrew-Chen-Wang
Copy link
Member

You're definitely in the wrong repository, but if you go to their README, you can see instructions: https://pypi.org/project/django-easy-pdf/ Following that, add it to your url patterns and you should be good to go.

Validating the session is dependent on what frontend you're using. If you're using regular HTML and JS, you definitely should not be using this repository and should be using the Django built-in session.

If you are using something like Angular JS or react, you'll have to build something yourself. We have an example Angular repository, but it uses a PR for the moment.

@juancresc
Copy link
Author

juancresc commented Jul 15, 2020 via email

@Andrew-Chen-Wang
Copy link
Member

Seems like the PDF view is using Django templates (mixin)? I guess that doesn't really matter, because the person's code is two lines long: https://github.com/nigma/django-easy-pdf/blob/master/easy_pdf/views.py#L81

I suggest you try to figure this out using a regular DRF view instead of their view. Just copy and paste some of their code. Like figure out how to manually code it into the DRF view. I don't have much time to help much further, so I'll have to close this.

TL;DR figure out how to copy-paste the package's view's code into a DRF view (e.g. APIView or ViewSet).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants