我想了解基于令牌的身份验证的含义.我搜索了互联网,但找不到任何可以理解的东西.
我正在使用TastyPie制作内部API.我有
from tastypie.authentication import ApiKeyAuthentication
class MyResource(ModelResource):
Meta:
authentication = ApiKeyAuthentication()
Run Code Online (Sandbox Code Playgroud)
禁用Auth规则后,我的API运行良好.有了它,无论我尝试什么,我都会收到401(未经授权)的回复.
我确信这是一旦你看到它在行动中非常明显的事情之一,但在此期间,请告知如何提出请求(GET).
Tastypie APIKey身份验证如何工作?我知道文档中提到了一个信号:
from django.contrib.auth.models import User
from django.db import models
from tastypie.models import create_api_key
models.signals.post_save.connect(create_api_key, sender=User)
Run Code Online (Sandbox Code Playgroud)
但是,什么时候被称为?如果我想向用户提供他们的API密钥,我知道我可以在APIKey数据库中找到这个create_api_key函数添加密钥,但是在何时何地调用此models.signals.post_save函数?
这只是另一款django型号吗?我觉得是这样的?
每次保存用户帐户时都会调用此命令吗?