众所周知(至少对于用百度作为第三方平台的人是的),百度账号登陆是真的很容易申请到一个id,但是,他有一个问题,就是:


很容易出错


我做这个东西的时候,至少弄出了不下十个错误。现在,我就告诉大家这些问题如何解决
1、百度开发者管理中心怎么进
回答:不要指望在百度上能直接找到连接,你只能点击下方链接进入,也不要指望在百度开发者中心主页进入,更不要指望着自己乱猜网址。
连接:http://developer.baidu.com/console#app/project点击此处跳转

(你要是乱打网址进去了,那么:欧皇,请受我一拜!)
2、怎么创建应用

点击创建工程(若按钮被百度隐藏,请点击此处或复制下方链接http://developer.baidu.com/console#app/create)

按提示填写相关信息
至此,创建工程就可以了

3、怎么登陆
这个问题可算是折腾我半天了。
1、初始设置

点击你要进入的工程

按图示填写信息,然后点击保存

====================
至此,你已经搞定了后台工作

====================
废话不多说,php代码直接上
1、注册(我是在注册时强制绑定百度账号的,但是如果你只是想作为一种第三方登陆工具,也可以参考,你可以只看获取code和access_token的部分

<?php//常量设置
header("charset=utf-8");//连接数据库$con = mysql_connect("localhost","这里填账号",这里填密码);if (!$con){die('Could not connect: ' . mysql_error());}mysql_select_db("sfydb_6273437", $con);//这说明是传回了code
if($_GET['code']!="")
{//判断是否已注册$result = mysql_query("SELECT * FROM userlist where Userid = '".$_GET['Userid']."'");$count=mysql_num_rows($result);if($count!=0){die("这个账号已经被注册过了");}//获取token$url="https://openapi.baidu.com/oauth/2.0/token?grant_type=authorization_code&code=".$_GET['code']."&client_id=BIPCjdmpveslLNrKovbStQ3t&client_secret=我当然不会告诉你secret是多少&redirect_uri=http://sscczzjj.top?Userid=".$_GET['Userid']."%26Password=".str_replace("=","%253D",$_GET['Password']);$html = file_get_contents($url);$TokenText = json_decode($html, true);//获取失败if($TokenText["error"]!=""){die($TokenText["error_description"]);}//读取资料$url="https://openapi.baidu.com/rest/2.0/passport/users/getLoggedInUser?access_token=".$TokenText['access_token'];$html = file_get_contents($url);$InfoText = json_decode($html, true);//判断此id是否已注册$result = mysql_query("SELECT * FROM userlist where Baiduuid = '".$InfoText['openid']."'");$count=mysql_num_rows($result);if($count!=0){die("此百度id已注册过一个账号");}//获取失败if($InfoText["error_msg"]!=""){die($InfoText["error_msg"]);}//写数据库mysql_query("INSERT INTO userlist (Userid, Password, AccessToken, UserName, Baiduuid, Cookie, RefershToken) VALUES ('".$Userid."', '".$Password."', '".$TokenText['access_token']."', '".$InfoText['uname']."', '".$InfoText['openid']."', '".$Cookie."', '".$TokenText['refresh_token']."')");//返回成功die("注册成功,请选择登陆操作进行登陆");
}//表明是由客户端发起注册请求
if($_GET['firstinto']!="")
{//判断是否已注册$result = mysql_query("SELECT * FROM userlist where Userid = '".$_GET['Userid']."'");$count=mysql_num_rows($result);if($count!=0){die("这个账号已经被注册过了");}//获取code$url="https://openapi.baidu.com/oauth/2.0/authorize?response_type=code&confirm_login=1&client_id=BIPCjdmpveslLNrKovbStQ3t&redirect_uri=http://sscczzjj.top?Userid=".$_GET['Userid']."%26Password=".str_replace("=","%253D",$_GET['Password']);Header("Location:$url");
}//加密
function encryptForDotNet($input, $key)
{$iv = $key;$addnum = 8 - ( strlen($input) % 8 );for ($i = 0; $i < $addnum; $i++){$input .= chr($addnum);}$output = mcrypt_encrypt(MCRYPT_DES, $key, $input, MCRYPT_MODE_CBC, $iv);return base64_encode($output);
}
//解密
function decryptForDotNet($input, $key)
{$iv = $key;$output = base64_decode($input);$output = mcrypt_decrypt(MCRYPT_DES, $key, $output, MCRYPT_MODE_CBC, $iv);for ($i = 0; $i <= 8; $i++){$output = str_replace(chr($i), "", $output);}return $output;
}
?>

2、登陆

<?php//常量设置
$con = mysql_connect("localhost","这里填写账号",这里填写密码);
if (!$con)
{die('Could not connect: ' . mysql_error());
}
mysql_select_db("sfydb_6273437", $con);
Login();//主函数
function Login()
{$Password=decryptForDotNet($_GET['Password'],"AA");$Userid=$_GET['Userid'];$result = mysql_query("SELECT * FROM userlist where Userid = '".$Userid."'");$count=mysql_num_rows($result);if($count==0){die("NoUser");}$row = mysql_fetch_array($result);if($row['Password']!=$_GET['Password']){die("WrongPassword");}if($row['BaiduUid']==""){die("NoToken.PleaseUseRegister");}//生成Cookie$Cookie = '';for ($i=1;$i<=1024;$i++){    $randstr = chr(rand(97,122));$Cookie .= $randstr; }$Cookie =encryptForDotNet($Cookie,"t68[]a*G");mysql_query("UPDATE userlist SET Cookie = '.$Cookie.' WHERE Userid='".$Userid."'");die("=".$Cookie);
}
//加密
function encryptForDotNet($input, $key)
{$iv = $key;$addnum = 8 - ( strlen($input) % 8 );for ($i = 0; $i < $addnum; $i++){$input .= chr($addnum);}$output = mcrypt_encrypt(MCRYPT_DES, $key, $input, MCRYPT_MODE_CBC, $iv);return base64_encode($output);
}
//解密
function decryptForDotNet($input, $key)
{$iv = $key;$output = base64_decode($input);$output = mcrypt_decrypt(MCRYPT_DES, $key, $output, MCRYPT_MODE_CBC, $iv);for ($i = 0; $i <= 8; $i++){$output = str_replace(chr($i), "", $output);}return $output;
}
?>

至此,后端搞定

废话还是不多说,再来个前端VBNET代码

1、代码


Imports System.Security.Cryptography
Imports System.Text
Imports System.IOPublic Class LoginPrivate Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.CheckedChangedIf CheckBox1.Checked = True ThenTextBox1.PasswordChar = ""TextBox2.PasswordChar = ""ElseTextBox1.PasswordChar = "*"TextBox2.PasswordChar = "*"End IfEnd SubPrivate Sub RadioButton1_Click(sender As Object, e As EventArgs) Handles RadioButton1.ClickTextBox1.Enabled = FalseGroupBox2.Enabled = FalseTextBox1.Text = ""End SubPrivate Sub RadioButton2_Click(sender As Object, e As EventArgs) Handles RadioButton2.ClickTextBox1.Enabled = TrueEnd SubPrivate Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.ClickDim LoginResult1 As String = ""If RadioButton1.Checked = True ThenLoginResult1 = CookieCenter.Password_Sign_in(TextBox3.Text, TextBox2.Text)If LoginResult1 <> "OK" ThenMsgBox(LoginResult1, MsgBoxStyle.Exclamation, "Error")End IfElseIf TextBox1.Text <> TextBox2.Text ThenMsgBox("DifferentPassword", MsgBoxStyle.Exclamation, "Error")ReturnEnd IfIf CookieCenter.CheckUnallowedChar(TextBox3.Text) = False OrElse CookieCenter.CheckUnallowedChar(TextBox2.Text) = False ThenMsgBox("IncludesUnecpectedChar", MsgBoxStyle.Exclamation, "Error")ReturnEnd IfIf TextBox3.Text.Length > 20 OrElse TextBox2.Text.Length > 20 ThenMsgBox("UserOrPasswordToLong", MsgBoxStyle.Exclamation, "Error")ReturnEnd IfIf TextBox3.Text.Length < 4 OrElse TextBox2.Text.Length < 6 ThenMsgBox("UserOrPasswordToShort", MsgBoxStyle.Exclamation, "Error")ReturnEnd IfGroupBox2.Enabled = TrueTextBox4.Text = "Http://sscczzjj.top/?firstinto=abc&Userid=" + TextBox3.Text + "&Password=" + SecurityCenter.EncriptStr(TextBox2.Text, "AA").Replace("=", "%3D")WebBrowser1.Url = New Uri("Http://sscczzjj.top/?firstinto=abc&Userid=" + TextBox3.Text + "&Password=" + SecurityCenter.EncriptStr(TextBox2.Text, "AA").Replace("=", "%3D"))'LoginResult1 = CookieCenter.Sign_up(TextBox3.Text, TextBox2.Text)End IfEnd Sub
End ClassPublic Class SecurityCenter '与php配套的加解密Public Shared Function EncriptStr(ByVal input As String, ByVal password As String, ByVal Optional encoding As Encoding = Nothing) As Stringencoding = If(encoding, Encoding.[Default])Dim iv = encoding.GetBytes(password)Dim key = encoding.GetBytes(password)Dim datas = encoding.GetBytes(input)Dim desCryptoServiceProvider = New DESCryptoServiceProvider()Using memoryStream = New MemoryStream()Using cryptoStream = New CryptoStream(memoryStream, desCryptoServiceProvider.CreateEncryptor(iv, key), CryptoStreamMode.Write)cryptoStream.Write(datas, 0, datas.Length)cryptoStream.FlushFinalBlock()Return Convert.ToBase64String(memoryStream.ToArray())End UsingEnd UsingEnd FunctionPublic Shared Function DecriptStr(ByVal input As String, ByVal password As String, ByVal Optional encoding As Encoding = Nothing) As Stringencoding = If(encoding, Encoding.[Default])Dim iv = encoding.GetBytes(password)Dim key = encoding.GetBytes(password)Dim datas = Convert.FromBase64String(input)Dim desCryptoServiceProvider = New DESCryptoServiceProvider()Using memoryStream = New MemoryStream()Using cryptoStream = New CryptoStream(memoryStream, desCryptoServiceProvider.CreateDecryptor(iv, key), CryptoStreamMode.Write)cryptoStream.Write(datas, 0, datas.Length)cryptoStream.FlushFinalBlock()Return encoding.GetString(memoryStream.ToArray())End UsingEnd UsingEnd Function
End ClassPublic Class HttpRequestionsPublic Shared Function POST(ByVal URL$, ByVal data$)Dim httpOn Error Resume Nexthttp = CreateObject("WinHttp.WinHttpRequest.5.1")With http.Open("POST", URL, True).Send(data) '发送请求.WaitForResponse() '一直等待到有回应再继续End WithDim request = http.responseText '此处用于储存返回的数据包http = Nothing '清理掉旧的http请求信息防止二次调用时裂开Return request '返回数据包End FunctionPublic Shared Function GET1(ByVal URL$)Dim httpOn Error Resume Nexthttp = CreateObject("WinHttp.WinHttpRequest.5.1")With http.Open("GET1", URL, True).Send() '发送请求.WaitForResponse() '一直等待到有回应再继续End WithDim request = http.responseText '此处用于储存返回的数据包http = Nothing '清理掉旧的http请求信息防止二次调用时裂开Return request '返回数据包End Function
End ClassPublic Class CookieCenterPublic Cookie1 As String = ""'Public Key As String = "gYt6&^a;"Public EPassword As String = ""Public Shared Function Password_Sign_in(ByVal User As String, ByVal Password As String) As StringIf CheckUnallowedChar(User) = False OrElse CheckUnallowedChar(Password) = False ThenReturn "IncludesUnecpectedChar"End IfIf User.Length > 20 OrElse Password.Length > 20 ThenReturn "UserOrPasswordToLong"End IfIf User.Length < 4 OrElse Password.Length < 6 ThenReturn "UserOrPasswordToShort"End IfDim result As String = ""result = HttpRequestions.POST("Http://sscczzjj.top/PasswordLogin.php?Userid=" + User + "&Password=" + SecurityCenter.EncriptStr(Password, "AAA"), "")If result.StartsWith("=") = True ThenMy.Settings("Cookie") = result.Replace("=", "")Return "OK"ElseMsgBox(result, MsgBoxStyle.Exclamation, "Error")Return "Failed"End IfEnd FunctionPublic Shared Function CheckUnallowedChar(ByVal CheckStringed As String) As BooleanFor i = 32 To 47If CheckStringed.Replace(ChrW(i), "") <> CheckStringed ThenReturn FalseEnd IfNextFor i = 58 To 63If CheckStringed.Replace(ChrW(i), "") <> CheckStringed ThenReturn FalseEnd IfNextFor i = 91 To 96If CheckStringed.Replace(ChrW(i), "") <> CheckStringed ThenReturn FalseEnd IfNextFor i = 123 To 127If CheckStringed.Replace(ChrW(i), "") <> CheckStringed ThenReturn FalseEnd IfNextReturn TrueEnd Function
End Class

2、设计器代码

<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class LoginInherits System.Windows.Forms.Form'Form 重写 Dispose,以清理组件列表。<System.Diagnostics.DebuggerNonUserCode()> _Protected Overrides Sub Dispose(ByVal disposing As Boolean)TryIf disposing AndAlso components IsNot Nothing Thencomponents.Dispose()End IfFinallyMyBase.Dispose(disposing)End TryEnd Sub'Windows 窗体设计器所必需的Private components As System.ComponentModel.IContainer'注意: 以下过程是 Windows 窗体设计器所必需的'可以使用 Windows 窗体设计器修改它。  '不要使用代码编辑器修改它。<System.Diagnostics.DebuggerStepThrough()> _Private Sub InitializeComponent()Me.WebBrowser1 = New System.Windows.Forms.WebBrowser()Me.TabControl1 = New System.Windows.Forms.TabControl()Me.LAR = New System.Windows.Forms.TabPage()Me.GroupBox2 = New System.Windows.Forms.GroupBox()Me.GroupBox1 = New System.Windows.Forms.GroupBox()Me.TextBox4 = New System.Windows.Forms.TextBox()Me.Label6 = New System.Windows.Forms.Label()Me.Label4 = New System.Windows.Forms.Label()Me.Button1 = New System.Windows.Forms.Button()Me.CheckBox1 = New System.Windows.Forms.CheckBox()Me.RadioButton2 = New System.Windows.Forms.RadioButton()Me.RadioButton1 = New System.Windows.Forms.RadioButton()Me.Label5 = New System.Windows.Forms.Label()Me.TextBox3 = New System.Windows.Forms.TextBox()Me.TextBox2 = New System.Windows.Forms.TextBox()Me.TextBox1 = New System.Windows.Forms.TextBox()Me.Label3 = New System.Windows.Forms.Label()Me.Label2 = New System.Windows.Forms.Label()Me.Label1 = New System.Windows.Forms.Label()Me.TabControl1.SuspendLayout()Me.LAR.SuspendLayout()Me.GroupBox2.SuspendLayout()Me.GroupBox1.SuspendLayout()Me.SuspendLayout()''WebBrowser1'Me.WebBrowser1.Dock = System.Windows.Forms.DockStyle.FillMe.WebBrowser1.Location = New System.Drawing.Point(3, 17)Me.WebBrowser1.MinimumSize = New System.Drawing.Size(20, 20)Me.WebBrowser1.Name = "WebBrowser1"Me.WebBrowser1.Size = New System.Drawing.Size(500, 464)Me.WebBrowser1.TabIndex = 0Me.WebBrowser1.Url = New System.Uri("", System.UriKind.Relative)''TabControl1'Me.TabControl1.Appearance = System.Windows.Forms.TabAppearance.ButtonsMe.TabControl1.Controls.Add(Me.LAR)Me.TabControl1.Dock = System.Windows.Forms.DockStyle.FillMe.TabControl1.ItemSize = New System.Drawing.Size(150, 21)Me.TabControl1.Location = New System.Drawing.Point(0, 0)Me.TabControl1.Name = "TabControl1"Me.TabControl1.SelectedIndex = 0Me.TabControl1.Size = New System.Drawing.Size(862, 521)Me.TabControl1.SizeMode = System.Windows.Forms.TabSizeMode.FixedMe.TabControl1.TabIndex = 1''LAR'Me.LAR.AutoScroll = TrueMe.LAR.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingleMe.LAR.Controls.Add(Me.GroupBox2)Me.LAR.Controls.Add(Me.GroupBox1)Me.LAR.Location = New System.Drawing.Point(4, 25)Me.LAR.Name = "LAR"Me.LAR.Padding = New System.Windows.Forms.Padding(3)Me.LAR.Size = New System.Drawing.Size(854, 492)Me.LAR.TabIndex = 0Me.LAR.Text = "Login And Register"Me.LAR.UseVisualStyleBackColor = True''GroupBox2'Me.GroupBox2.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrinkMe.GroupBox2.Controls.Add(Me.WebBrowser1)Me.GroupBox2.Dock = System.Windows.Forms.DockStyle.RightMe.GroupBox2.Enabled = FalseMe.GroupBox2.Location = New System.Drawing.Point(343, 3)Me.GroupBox2.Name = "GroupBox2"Me.GroupBox2.Size = New System.Drawing.Size(506, 484)Me.GroupBox2.TabIndex = 3Me.GroupBox2.TabStop = FalseMe.GroupBox2.Text = "未授权用户可以在这里授权"''GroupBox1'Me.GroupBox1.Controls.Add(Me.TextBox4)Me.GroupBox1.Controls.Add(Me.Label6)Me.GroupBox1.Controls.Add(Me.Label4)Me.GroupBox1.Controls.Add(Me.Button1)Me.GroupBox1.Controls.Add(Me.CheckBox1)Me.GroupBox1.Controls.Add(Me.RadioButton2)Me.GroupBox1.Controls.Add(Me.RadioButton1)Me.GroupBox1.Controls.Add(Me.Label5)Me.GroupBox1.Controls.Add(Me.TextBox3)Me.GroupBox1.Controls.Add(Me.TextBox2)Me.GroupBox1.Controls.Add(Me.TextBox1)Me.GroupBox1.Controls.Add(Me.Label3)Me.GroupBox1.Controls.Add(Me.Label2)Me.GroupBox1.Controls.Add(Me.Label1)Me.GroupBox1.Dock = System.Windows.Forms.DockStyle.LeftMe.GroupBox1.Location = New System.Drawing.Point(3, 3)Me.GroupBox1.Name = "GroupBox1"Me.GroupBox1.Size = New System.Drawing.Size(334, 484)Me.GroupBox1.TabIndex = 2Me.GroupBox1.TabStop = FalseMe.GroupBox1.Text = "登陆"''TextBox4'Me.TextBox4.Location = New System.Drawing.Point(77, 207)Me.TextBox4.Name = "TextBox4"Me.TextBox4.ReadOnly = TrueMe.TextBox4.Size = New System.Drawing.Size(248, 21)Me.TextBox4.TabIndex = 13''Label6'Me.Label6.AutoSize = TrueMe.Label6.Location = New System.Drawing.Point(18, 210)Me.Label6.Name = "Label6"Me.Label6.Size = New System.Drawing.Size(53, 12)Me.Label6.TabIndex = 12Me.Label6.Text = "你的链接"''Label4'Me.Label4.AutoSize = TrueMe.Label4.Location = New System.Drawing.Point(18, 131)Me.Label4.Name = "Label4"Me.Label4.Size = New System.Drawing.Size(299, 72)Me.Label4.TabIndex = 1Me.Label4.Text = "1、为了防止某些别有用心的人随意注册账号,注册需要" & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & "与百度账号绑定,输入完密码之后您可以获得激活链" & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & "接,您可以复制链接后在浏览器打开以完成验证,也" & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & "可以在右" &"侧的窗口中登陆百度账号验证" & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & "2、链接中包含密码的密文,请勿外泄" & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & "3、在授权成功之前,此账号仍可被其他用户注册"''Button1'Me.Button1.Location = New System.Drawing.Point(250, 99)Me.Button1.Name = "Button1"Me.Button1.Size = New System.Drawing.Size(75, 23)Me.Button1.TabIndex = 11Me.Button1.Text = "执行"Me.Button1.UseVisualStyleBackColor = True''CheckBox1'Me.CheckBox1.AutoSize = TrueMe.CheckBox1.Location = New System.Drawing.Point(172, 102)Me.CheckBox1.Name = "CheckBox1"Me.CheckBox1.Size = New System.Drawing.Size(72, 16)Me.CheckBox1.TabIndex = 10Me.CheckBox1.Text = "显示密码"Me.CheckBox1.UseVisualStyleBackColor = True''RadioButton2'Me.RadioButton2.AutoSize = TrueMe.RadioButton2.Location = New System.Drawing.Point(119, 102)Me.RadioButton2.Name = "RadioButton2"Me.RadioButton2.Size = New System.Drawing.Size(47, 16)Me.RadioButton2.TabIndex = 9Me.RadioButton2.TabStop = TrueMe.RadioButton2.Text = "注册"Me.RadioButton2.UseVisualStyleBackColor = True''RadioButton1'Me.RadioButton1.AutoSize = TrueMe.RadioButton1.Checked = TrueMe.RadioButton1.Location = New System.Drawing.Point(66, 102)Me.RadioButton1.Name = "RadioButton1"Me.RadioButton1.Size = New System.Drawing.Size(47, 16)Me.RadioButton1.TabIndex = 8Me.RadioButton1.TabStop = TrueMe.RadioButton1.Text = "登陆"Me.RadioButton1.UseVisualStyleBackColor = True''Label5'Me.Label5.AutoSize = TrueMe.Label5.Location = New System.Drawing.Point(30, 104)Me.Label5.Name = "Label5"Me.Label5.Size = New System.Drawing.Size(29, 12)Me.Label5.TabIndex = 7Me.Label5.Text = "操作"''TextBox3'Me.TextBox3.Location = New System.Drawing.Point(65, 18)Me.TextBox3.Name = "TextBox3"Me.TextBox3.Size = New System.Drawing.Size(260, 21)Me.TextBox3.TabIndex = 5''TextBox2'Me.TextBox2.Location = New System.Drawing.Point(65, 45)Me.TextBox2.Name = "TextBox2"Me.TextBox2.PasswordChar = Global.Microsoft.VisualBasic.ChrW(42)Me.TextBox2.Size = New System.Drawing.Size(260, 21)Me.TextBox2.TabIndex = 4''TextBox1'Me.TextBox1.Enabled = FalseMe.TextBox1.Location = New System.Drawing.Point(65, 72)Me.TextBox1.Name = "TextBox1"Me.TextBox1.PasswordChar = Global.Microsoft.VisualBasic.ChrW(42)Me.TextBox1.Size = New System.Drawing.Size(260, 21)Me.TextBox1.TabIndex = 3''Label3'Me.Label3.AutoSize = TrueMe.Label3.Location = New System.Drawing.Point(6, 75)Me.Label3.Name = "Label3"Me.Label3.Size = New System.Drawing.Size(53, 12)Me.Label3.TabIndex = 2Me.Label3.Text = "确认密码"''Label2'Me.Label2.AutoSize = TrueMe.Label2.Location = New System.Drawing.Point(30, 48)Me.Label2.Name = "Label2"Me.Label2.Size = New System.Drawing.Size(29, 12)Me.Label2.TabIndex = 1Me.Label2.Text = "密码"''Label1'Me.Label1.AutoSize = TrueMe.Label1.Location = New System.Drawing.Point(30, 21)Me.Label1.Name = "Label1"Me.Label1.Size = New System.Drawing.Size(29, 12)Me.Label1.TabIndex = 0Me.Label1.Text = "账号"''Login'Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 12.0!)Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.FontMe.ClientSize = New System.Drawing.Size(862, 521)Me.Controls.Add(Me.TabControl1)Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingleMe.MaximizeBox = FalseMe.Name = "Login"Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreenMe.Text = "Login"Me.TabControl1.ResumeLayout(False)Me.LAR.ResumeLayout(False)Me.GroupBox2.ResumeLayout(False)Me.GroupBox1.ResumeLayout(False)Me.GroupBox1.PerformLayout()Me.ResumeLayout(False)End SubFriend WithEvents WebBrowser1 As WebBrowserFriend WithEvents TabControl1 As TabControlFriend WithEvents LAR As TabPageFriend WithEvents GroupBox2 As GroupBoxFriend WithEvents GroupBox1 As GroupBoxFriend WithEvents Button1 As ButtonFriend WithEvents CheckBox1 As CheckBoxFriend WithEvents RadioButton2 As RadioButtonFriend WithEvents RadioButton1 As RadioButtonFriend WithEvents Label5 As LabelFriend WithEvents TextBox3 As TextBoxFriend WithEvents TextBox2 As TextBoxFriend WithEvents TextBox1 As TextBoxFriend WithEvents Label3 As LabelFriend WithEvents Label2 As LabelFriend WithEvents Label1 As LabelFriend WithEvents TextBox4 As TextBoxFriend WithEvents Label6 As LabelFriend WithEvents Label4 As Label
End Class

至此,前端搞定

好啦,现在你可以用百度账号登陆啦

4、根域名相同但是还是redirect_uri错误
回答:别想啦,根域名验证是没用的,只能通过校验回调页来搞

5、为什么没有uid
回答:很简单,百度的文档太久了,实际获得的是openid而不是uid

6、如何获得code
回答:这是通过将code追加在redir_uri之后并重定向到这个uri来实现,所以你需要一个页面来接受这个code

7、redir_uri后面能带参数吗
回答:能,这个百度还是做得到的,他会用&code=xxx的形式追加

8、如何获得code
回答:其实没有百度说的那么复杂,就是将内容直接发回给当前网址,你可以像发送POST或GET请求一样,直接获取返回的json包。但你需要注意,这里的redirect_uri必须和code中的redirect_uri的网址一样(不包括参数),建议直接将获取code与获取token放在一个网址中(我就是这么做的)

9、可以正常获取code,但是得不到token
回答:token中的redirect_uri必须是获取code时填写的uri
例如:在您获取code时输入http://sscczzjj.top/作为redirect_uri,那么在你获取token也要用http://sscczzjj.top作为redirect_uri,而不能用http://sscczzjj.top/1作为uri(即使你将他们都添加到回调uri中)

10、只能填一个授权回调地址
回答:很抱歉,我没研究出来这个问题如何解决,所以我干脆就只写一个,嘿嘿嘿。

11、授权回调地址要填参数吗
回答:不要填,也不需要,百度不会管这个回调地址后面的参数,他只关心地址

以上就是全部内容,如果您还有别的疑问,请留言

开发不容易,发文也不容易,独自解决问题也不容易,客官您喜欢就三连一下吧

关于百度oauth2.0登陆的诸多问题相关推荐

  1. OAuth2.0协议入门(一):OAuth2.0协议的基本概念以及使用授权码模式(authorization code)实现百度账号登录

    一 OAuth2.0协议的基本概念 (1)OAuth2.0协议 OAuth协议,是一种授权协议,不涉及具体的代码,只是表示一种约定的流程和规范.OAuth协议一般用于用户决定是否把自己在某个服务商上面 ...

  2. Oauth2.0 QQ微信微博实现第三方登陆

    一.写在前面 目前对于大多数的App或Web网站都支持有第三方登陆这个功能,用户可使用 QQ/ 微信/ 微博 帐号快速登录你的网站,降低注册门槛,为你的网站带来海量新用户.最近在新项目上刚好用到了,在 ...

  3. QQ互联OAuth2.0 .NET SDK 发布以及网站QQ登陆示例代码(转)

    OAuth: OAuth(开放授权)是一个开放标准,允许用户授权第三方网站访问他们存储在另外的服务提供者上的信息,而不需要将用户名和密码提供给第三方网站或分享他们数据的所有内容. QQ登录OAuth2 ...

  4. QQ互联OAuth2.0 .NET SDK 发布以及网站QQ登陆示例代码

    OAuth: OAuth(开放授权)是一个开放标准,允许用户授权第三方网站访问他们存储在另外的服务提供者上的信息,而不需要将用户名和密码提供给第三方网站或分享他们数据的所有内容. QQ登录OAuth2 ...

  5. Oauth2.0 安全性(以微信授权登陆为例)

    前言 用户 A 要使用微信账号登陆 Z 平台(www.z.com),一个黑客 H 想要把使用微信账号登陆 Z 平台的用户 A 转到恶意网站(www.h.com)来侵犯 A 的隐私 为什么要校验 red ...

  6. Go实战--golang中OAuth2.0的使用(使用google账号进行登陆验证)

    生命不止,继续 go go go!!! 今天继续分享golang中的认证问题,之前写过两篇: 一篇是关于basic认证:Go实战–通过basic认证的http(basic authentication ...

  7. 详解比springSecurity和shiro更简单优雅的轻量级Sa-Token框架,比如登录认证,权限认证,单点登录,OAuth2.0,分布式Session会话,微服务网关鉴权

    文章目录 1. 技术选型 2. Sa-Token概述 2.1 简单介绍 2.2 登录认证 2.3 权限认证 3. 功能一览 4. Sa-Token使用 4.1 引入Sa-Token依赖 4.2 Sa- ...

  8. Java架构-(十) 整合spring cloud云架构 - SSO单点登录之OAuth2.0登录认证(1)

    之前写了很多关于spring cloud的文章,今天我们对OAuth2.0的整合方式做一下笔记,首先我从网上找了一些关于OAuth2.0的一些基础知识点,帮助大家回顾一下知识点: 一.oauth中的角 ...

  9. Oauth2.0搭建开放平台接口

    开放平台 类似qq互联.微信开放平台和蚂蚁金服开放平台等,可以实现qq联合登陆.微信扫码登陆等.在大型公司中,公司旗下的分公司等相互通讯也可以采用开放平台形式对接口进行授权使用. Oauth 一个开放 ...

最新文章

  1. Linux两种定时器
  2. 笑谈软件工程:烽烟中的敏捷
  3. pfSense 2.3.5发布!汉化包同步发布!
  4. (C语言)字符串大小写无关查找替换
  5. 如果多个用户同时修改同一客户记录,而且先后提交修改,Oracle 怎样保证该客户记录...
  6. php验证注册不能纯数字,php写一个纯数字验证码教学
  7. php_D3_“简易聊天室 ”实现的关键技术 详解
  8. java世博会_世博会申请由xcode修改
  9. ubuntu java 中文_java部署ubuntu后中文显示问号问题
  10. python打开txt文件
  11. CentOS7常用工具包安装
  12. centos下Vim编辑器配置
  13. 视频直播画质核心影响因素分析:分辨率、帧率和码率
  14. 超级AI买家阿里巴巴
  15. 基于java(springboot框架)旅游景区景点购票系统 java毕业设计选题课题作品 毕业论文
  16. 中南大学计算机大一学什么时候发,中南大学计算机学院2019年夏令营
  17. calfcamel 的 2333
  18. 如何用计算机巧记英语词汇,小学英语单词巧记法
  19. 人工智能+大数据+云计算
  20. html2canvas实现一键截图

热门文章

  1. 算法 | 03 字符串(KMP)
  2. ecw2c理解元数据:使用BigQuery k-means将4,000个堆栈溢出标签聚类
  3. 如何用matlab画负倒函数曲线,负倒描述函数
  4. 学习笔记:《机器人SLAM导航核心技术与实战》序言
  5. 3600、宝石与石头
  6. 我有一个梦,袁隆平!
  7. c语言程序设计流星雨,流星雨的实现C语言程序设计
  8. Android P版本应用兼容性适配技术指导
  9. vs code使用Easy Sass插件编译sass文件路径报错问题解决
  10. HQL 报 return code 2 from org.apache.hadoop.hive.ql.exec.mr.MapRedTask 错误解决方案