HMAC Hash Message Authentication Code
核心思路
提示:private key不传输
http://docs.aws.amazon.com/general/latest/gr/sigv4-create-string-to-sign.html
http://docs.aws.amazon.com/general/latest/gr/sigv4-calculate-signature.html
http://www.thebuzzmedia.com/designing-a-secure-rest-api-without-oauth-authentication/
Developers are issued an AWS access key ID and AWS secret access key when they register.
The Amazon S3 REST API uses the standard HTTP Authorization header to pass authentication information.
Authorization: AWS AWSAccessKeyId:Signature
开发者在注册的时候,会得到一个AWS access key ID和AWS secret access key。关于请求认证,
AWSAccessKeyId用来计算signature以及标识是哪一个开发者发起的请求。
Signature是请求中选定元素的RFC 2104 HMAC-SHA1算法生成的。
Authorization = "AWS" + " " + AWSAccessKeyId + ":" + Signature;
Signature = Base64( HMAC-SHA1( YourSecretAccessKeyID, UTF-8-Encoding-Of( StringToSign ) ) )
http://docs.aws.amazon.com/AmazonS3/latest/dev/RESTAuthentication.html#ConstructingTheAuthenticationHeader
https
curl例子
curl -X $HTTP_METHOD -H "Authorization: Bearer $TOKEN" "https://api.digitalocean.com/v2/$OBJECT"
curl -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" -d '{"name": "example.com", "ip_address": "127.0.0.1"}' -X POST "https://api.digitalocean.com/v2/domains"
https://developers.digitalocean.com/documentation/v2/#authentication
微信开发接口调用凭据
步骤
http://wiki.connect.qq.com/openapi调用说明_oauth2-0
无需登录授权的api直接使用
需要登录授权的使用OAuth2协议,获取到access_token,发送请求时提供access_token
http://open.weibo.com/wiki/授权机制说明
OAuth2协议
http://wiki.connect.qq.com/oauth2-0简介