您不妨使用OAuth2,因为这基本上就是您正在实施的。请参见“4.3资源所有者密码凭证授权。”:http://tools.ietf.org/html/rfc6749#section-4.3
在OAuth2用户的请求是这样的(例如,从RFC):
POST /token HTTP/1.1
Host: server.example.com
Authorization: Basic czZCaGRSa3F0MzpnWDFmQmF0M2JW
Content-Type: application/x-www-form-urlencoded
grant_type=password&username=johndoe&password=A3ddj3w
用于授权客户端应用程序的“授权”报头的使用,正文中的用户名/密码是您用户的凭据。
这里是对应的响应:
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Cache-Control: no-store
Pragma: no-cache
{
"access_token":"2YotnFZFEjr1zCsicMWpAA",
"token_type":"example",
"expires_in":3600,
"refresh_token":"tGzv3JOkF0XG5Qx2TlKWIA",
"example_parameter":"example_value"
}
OAuth2用户需要用于安全TLS/SSL(如brazo还回答)。