微信网页登录openid

1、获取code
2、https://api.weixin.qq.com/sns/oauth2/access_token?appid=--&secret=--&code=--&grant_type=authorization_code
3、获取access_token和openid
4、https://api.weixin.qq.com/sns/userinfo?access_token=--&openid=--&lang=zh_CN
5、获取用户信息

JS-SDK使用权限签名的C#实现

测试用例输入

noncestr=Wm3WZYTPz0wzccnW
jsapi_ticket=sM4AOVdWfPE4DxkXGEs8VMCPGGVi4C3VM0P37wVUCFvkVAy_90u5h9nbSlYy3-Sl-HhTdfl2fzFy1AOcHKP7qg
timestamp=1414587457
url=http://mp.weixin.qq.com?params=value

输出

0f9de62fce790f9a083d5c99e95740ceb90c27ed

测试代码

string noncestr = "Wm3WZYTPz0wzccnW";
string jsapi_ticket = "sM4AOVdWfPE4DxkXGEs8VMCPGGVi4C3VM0P37wVUCFvkVAy_90u5h9nbSlYy3-Sl-HhTdfl2fzFy1AOcHKP7qg";
string timestamp = "1414587457";
string url = "http://mp.weixin.qq.com?params=value";
string string1 = "jsapi_ticket=sM4AOVdWfPE4DxkXGEs8VMCPGGVi4C3VM0P37wVUCFvkVAy_90u5h9nbSlYy3-Sl-HhTdfl2fzFy1AOcHKP7qg&noncestr=Wm3WZYTPz0wzccnW&timestamp=1414587457&url=http://mp.weixin.qq.com?params=value";

SHA1 hash = SHA1.Create();
hash.ComputeHash(Encoding.UTF8.GetBytes(string1));
string signature = BitConverter.ToString(hash.Hash, 0).Replace("-", string.Empty).ToLower();

参考文档:
https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/JS-SDK.html(附录一)