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 can it support TokenAuthentication #122

Open
diluke1600 opened this issue Jan 22, 2016 · 3 comments
Open

how can it support TokenAuthentication #122

diluke1600 opened this issue Jan 22, 2016 · 3 comments
Assignees

Comments

@diluke1600
Copy link

No description provided.

@jhermann
Copy link
Contributor

You have to be quite more concrete, and define "TokenAuthentication", to get any kind of helpful answer.

@rocktavious
Copy link

rocktavious commented Jul 12, 2016

This is how i've been doing it against my services that are using django-rest-framework

import slumber

class CUSTOMAPI(slumber.API):
    def __init__(self, *args, **kwargs):
        token = kwargs.pop('token', None)
        super(CUSTOMAPI, self).__init__(*args, **kwargs)
        if token is None:
            data = dict(zip(["username", "password"],
                            self._store["session"].auth))
            token = self.token.post(data=data)["token"]
        self._store['session'].auth = None
        self._store['session'].headers['Authorization'] = "Token " + token

    def _get_resource(self, **kwargs):
        return self.resource_class(**kwargs)

Would be nice if this was somehow built-in to slumber since its the recommended tool of choice for using it against django-rest-framework

@samgiles samgiles self-assigned this Sep 6, 2016
@Lcstyle
Copy link

Lcstyle commented Feb 13, 2018

any traction on this, seems like a no-brainer to put the token in the auth header for DRF.

@rocktavious's code definitely works though, was able to move forward with that workaround.

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

No branches or pull requests

5 participants