[{"data":1,"prerenderedAt":235},["ShallowReactive",2],{"archive-2014-11-1":3},{"title":4,"articles":5,"hot_article":28,"month_arch":83,"total":231,"cover":232},"2014年11月 - 独孤影的博客",[6,16],{"id":7,"title":8,"uri":8,"author":9,"tags":10,"created_at":13,"view_count":14,"content":15},20,"用github登录，oauth开发","duguying",[11,12],"github","oauth","2014-11-23 13:33:37",9115,"\u003Cp>最近做的\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fduguying\u002Fojsite\" target=\"_blank\" title=\"https:\u002F\u002Fgithub.com\u002Fduguying\u002Fojsite\">oj\u003C\u002Fa>项目的网站子项目中要使用到“用github登录”这一功能，也就是oauth，于是研究了一番。\u003C\u002Fp>\u003Cp>github的oauth验证的过程如下：\u003C\u002Fp>\u003Cp>\u003Cspan style=\"font-size: 12.5px;\">用户访问登录验证接入口\u003C\u002Fspan>\u003C\u002Fp>\u003Cblockquote>\u003Cp>\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Flogin\u002Foauth\u002Fauthorize?client_id=xxxxxxxxxxxxxxxxxx&scope=user,public_repo\" _src=\"https:\u002F\u002Fgithub.com\u002Flogin\u002Foauth\u002Fauthorize?client_id=xxxxxxxxxxxxxxxxxx&scope=user,public_repo\" style=\"font-size: 12.5px;\">https:\u002F\u002Fgithub.com\u002Flogin\u002Foauth\u002Fauthorize?client_id=xxxxxxxxxxxxxxxxxx&amp;scope=user,public_repo\u003C\u002Fa>\u003Cspan style=\"font-size: 12.5px;\">&nbsp;\u003C\u002Fspan>\n &nbsp; &nbsp;\u003C\u002Fp>\u003C\u002Fblockquote>\u003Cp>\u003Cspan style=\"font-size: 12.5px;\">其中client_id由开发者在github网站上申请，无限制。\u003C\u002Fspan>\u003Cbr\u002F>\u003Cimg src=\"\u002F\u002Fduguying.oss-cn-qingdao.aliyuncs.com\u002F2014\u002F11\u002F23\u002Fregistor_github_oauth.png\" title=\"\" alt=\"registor_github_oauth.png\"\u002F>\u003Cbr\u002F>申请成功后，获取client_id和client_secret\u003Cbr\u002F>\u003Cimg src=\"\u002F\u002Fduguying.oss-cn-qingdao.aliyuncs.com\u002F2014\u002F11\u002F23\u002Fget_github_oauth_id_secret.png\" title=\"\" alt=\"get_github_oauth_id_secret.png\"\u002F>\u003C\u002Fp>\u003Cp>用户访问上面的url之后，github会让其跳转到你预定的url，并且带上code参数，例如\u003C\u002Fp>\u003Cblockquote>\u003Cp>\u003Ca href=\"http:\u002F\u002Foj.duguying.net\u002Foauth\u002Fgithub?code=xxxxxxxxxxxxxxxxxx\" style=\"font-size: 12.5px;\">http:\u002F\u002Foj.duguying.net\u002Foauth\u002Fgithub?code=xxxxxxxxxxxxxxxxxx\u003C\u002Fa>\u003Cspan style=\"font-size: 12.5px;\">&nbsp;\u003C\u002Fspan>\u003Cbr\u002F>\n &nbsp; &nbsp;\u003C\u002Fp>\u003C\u002Fblockquote>\u003Cp>然后，开发者可以通过code,client_id以及client_secret这三个参数获取用户的access_token即用户身份标识，请求如下\u003C\u002Fp>\u003Cblockquote>\u003Cp>\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Flogin\u002Foauth\u002Faccess_token?client_id=xxxxxxxxxxxxxxxxxxx&client_secret=xxxxxxxxxxxxxxxxx&code=xxxxxxxxxxxxxxxxxxx\" _src=\"https:\u002F\u002Fgithub.com\u002Flogin\u002Foauth\u002Faccess_token?client_id=xxxxxxxxxxxxxxxxxxx&client_secret=xxxxxxxxxxxxxxxxx&code=xxxxxxxxxxxxxxxxxxx\">https:\u002F\u002Fgithub.com\u002Flogin\u002Foauth\u002Faccess_token?client_id=xxxxxxxxxxxxxxxxxxx&amp;client_secret=xxxxxxxxxxxxxxxxx&amp;code=xxxxxxxxxxxxxxxxxxx\u003C\u002Fa>&nbsp;\u003C\u002Fp>\u003C\u002Fblockquote>\u003Cp>这个请求将会返回如下内容&nbsp;\u003C\u002Fp>\u003Cblockquote>\u003Cp>access_token=xxxxxxxxxxxxxxxxxxxxxxxxx&amp;scope=public_repo%2Cuser&amp;token_type=bearer&nbsp;\u003C\u002Fp>\u003C\u002Fblockquote>\u003Cp>有了access_token之后，只需要通过如下请求就可以获取用户信息\u003C\u002Fp>\u003Cblockquote>\u003Cp>\u003Ca href=\"https:\u002F\u002Fapi.github.com\u002Fuser?access_token=xxxxxxxxxxxxxxxxxxxxxxxxx\" _src=\"https:\u002F\u002Fapi.github.com\u002Fuser?access_token=xxxxxxxxxxxxxxxxxxxxxxxxx\">https:\u002F\u002Fapi.github.com\u002Fuser?access_token=xxxxxxxxxxxxxxxxxxxxxxxxx\u003C\u002Fa>&nbsp;\u003C\u002Fp>\u003C\u002Fblockquote>\u003Cp>返回的信息将会是json格式。注意整个请求过程中都是使用GET请求。只要理解了oauth验证过程，如此就很容易编程实现了。\u003C\u002Fp>\u003Cp>最后，附上我自己用golang实现的github的oauth验证库\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fgogather\u002Foauth\" target=\"_blank\" title=\"https:\u002F\u002Fgithub.com\u002Fgogather\u002Foauth\">https:\u002F\u002Fgithub.com\u002Fgogather\u002Foauth\u003C\u002Fa> 。\u003C\u002Fp>",{"id":17,"title":18,"uri":18,"author":9,"tags":19,"created_at":25,"view_count":26,"content":27},19,"texlive中文书签乱码",[20,21,22,23,24],"texlive","pdf","中文","书签","乱码","2014-11-15 02:54:01",8466,"\u003Cp>一个纠结了两天的问题，我之前在ctex环境下的\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fduguying\u002Freport\" target=\"_blank\" title=\"https:\u002F\u002Fgithub.com\u002Fduguying\u002Freport\">latex项目\u003C\u002Fa>迁移到texlive环境出现的问题。我之前的项目是gbk编码的，用ctex环境编译，因此，也只能够支持windows环境，故而，我将其转移到了texlive环境编写，字符集也由原来的gbk变为了utf8，这时出现问题了，起初解决书签乱码的方法是在编译过程中将生成的bachelor.out文件的编码由原来的gbk转为unicode，使用的是一个命令行工具gbk2uni.exe，可是现在全部变为utf8格式了out文件也不再是gbk，原来的转换方法无效了，后来也试着吧utf8格式的out文件转为unicode格式，可是还是无效，纠结很久，解决方法如下。\u003C\u002Fp>\u003Cp>原文档头部如下\u003Cbr\u002F>\u003C\u002Fp>\u003Cpre class=\"brush:tex;toolbar:false\">\\documentclass{article}&nbsp;&nbsp;&nbsp;&nbsp;\n\\usepackage{amsmath,amssymb}&nbsp;&nbsp;&nbsp;&nbsp;\n\\usepackage{latexsym}&nbsp;&nbsp;&nbsp;&nbsp;\n\\usepackage{CJK}&nbsp;&nbsp;&nbsp;&nbsp;\n\\usepackage{listings,xcolor}&nbsp;&nbsp;&nbsp;&nbsp;\n\\usepackage{graphicx}&nbsp;&nbsp;&nbsp;&nbsp;\n\\usepackage{titlesec}&nbsp;&nbsp;&nbsp;&nbsp;\n\\usepackage[dvipdfm,&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pdfstartview=FitH,&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CJKbookmarks=true,&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bookmarksnumbered=true,&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bookmarksopen=true,&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;colorlinks=true,&nbsp;%注释掉此项则交叉引用为彩色边框(将colorlinks和pdfborder同时注释掉)&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;%pdfborder=001,&nbsp;&nbsp;&nbsp;%注释掉此项则交叉引用为彩色边框&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;citecolor=magenta,%&nbsp;magenta&nbsp;,&nbsp;cyan&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;linkcolor=blue,&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;linktocpage=true,&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;]{hyperref}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;%&nbsp;hyperref&nbsp;宏包通常要求放在导言区的最后!!!&nbsp;&nbsp;&nbsp;&nbsp;\n\\usepackage{titletoc}\u003C\u002Fpre>\u003Cp>修改为\u003Cbr\u002F>\u003C\u002Fp>\u003Cpre class=\"brush:tex;toolbar:false\">\\documentclass{ctexartutf8}\n\\usepackage{amsmath,amssymb}\n\\usepackage{latexsym}\n\\usepackage{CJKutf8}\n\\usepackage{listings,xcolor}\n\\usepackage{graphicx}\n\\usepackage{titlesec}\n\n\\usepackage[unicode,dvipdfm,\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pdfstartview=FitH,\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;colorlinks=true,&nbsp;%注释掉此项则交叉引用为彩色边框(将colorlinks和pdfborder同时注释掉)\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;%pdfborder=001,&nbsp;&nbsp;&nbsp;%注释掉此项则交叉引用为彩色边框\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;citecolor=magenta,%&nbsp;magenta&nbsp;,&nbsp;cyan\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;linkcolor=blue,\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;linktocpage=true,\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;]{hyperref}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;%&nbsp;hyperref&nbsp;宏包通常要求放在导言区的最后!!!\n\\usepackage{titletoc}\u003C\u002Fpre>\u003Cp>其中主要是将CJK包改为CJKutf8，另外原来需要开启CJKbookmark=true这些都不要了，当然\u003Ccode>\\documentclass\u003C\u002Fcode>需要改为支持CJKutf8的格式，比如ctexartutf8等。\u003C\u002Fp>\u003Cp>这个问题的的确确困扰了我至少两天的时间，最终还是在google上搜索错误信息\u003Ccode>! Argument of \\HyPsd@GetTwoBytes has an extra }\u003C\u002Fcode>.找到一封邮件（\u003Ca href=\"http:\u002F\u002Flists.ffii.org\u002Fpipermail\u002Fcjk\u002F2007-February\u002F001832.html\" target=\"_blank\" title=\"http:\u002F\u002Flists.ffii.org\u002Fpipermail\u002Fcjk\u002F2007-February\u002F001832.html\">http:\u002F\u002Flists.ffii.org\u002Fpipermail\u002Fcjk\u002F2007-February\u002F001832.html\u003C\u002Fa>），这才恍然大悟。\u003C\u002Fp>",{"title":29,"list":30},"最热文章",[31,37,43,45,51,57,59,65,71,77],{"id":32,"title":33,"uri":34,"author":9,"created_at":35,"view_count":36},28,"docker容器目录与主机目录同步","\u002Farticle\u002Fdocker容器目录与主机目录同步","2014-12-31 12:34:08",15573,{"id":38,"title":39,"uri":40,"author":9,"created_at":41,"view_count":42},21,"beego中使用fis","\u002Farticle\u002Fbeego中使用fis","2014-12-03 10:47:56",9253,{"id":7,"title":8,"uri":44,"author":9,"created_at":13,"view_count":14},"\u002Farticle\u002F用github登录，oauth开发",{"id":46,"title":47,"uri":48,"author":9,"created_at":49,"view_count":50},18,"windows服务注册工具nssm","\u002Farticle\u002Fwindows服务注册工具nssm","2014-10-31 21:34:39",9054,{"id":52,"title":53,"uri":54,"author":9,"created_at":55,"view_count":56},49,"用latex排版中文书籍","\u002Farticle\u002F用latex排版中文书籍","2016-10-31 11:12:02",8645,{"id":17,"title":18,"uri":58,"author":9,"created_at":25,"view_count":26},"\u002Farticle\u002Ftexlive中文书签乱码",{"id":60,"title":61,"uri":62,"author":9,"created_at":63,"view_count":64},6,"Windows上的软件包管理器chocolatey","\u002Farticle\u002FWindows上的软件包管理器chocolatey","2014-08-10 15:55:22",8012,{"id":66,"title":67,"uri":68,"author":9,"created_at":69,"view_count":70},3,"利用开源和免费资源搭建CI环境","\u002Farticle\u002F利用开源和免费资源搭建CI环境","2014-07-04 16:54:58",7740,{"id":72,"title":73,"uri":74,"author":9,"created_at":75,"view_count":76},16,"php-fpm网站目录权限配置","\u002Farticle\u002Fphp-fpm网站目录权限配置","2014-10-18 01:36:10",7276,{"id":78,"title":79,"uri":80,"author":9,"created_at":81,"view_count":82},27,"sublime text 2插件开发，外部修改文件无法重新加载","\u002Farticle\u002Fsublime text 2插件开发，外部修改文件无法重新加载","2014-12-26 20:24:13",7055,{"title":84,"list":85},"按月归档",[86,90,93,96,99,102,105,109,113,116,119,122,126,129,132,136,139,142,145,149,152,155,158,161,164,167,170,173,176,179,182,185,188,191,194,197,200,203,206,209,213,216,219,222,225,228],{"title":87,"uri":88,"view_count":89},"2026年7月","\u002Farchive\u002F2026\u002F7\u002F1","[1]",{"title":91,"uri":92,"view_count":89},"2026年1月","\u002Farchive\u002F2026\u002F1\u002F1",{"title":94,"uri":95,"view_count":89},"2025年4月","\u002Farchive\u002F2025\u002F4\u002F1",{"title":97,"uri":98,"view_count":89},"2024年6月","\u002Farchive\u002F2024\u002F6\u002F1",{"title":100,"uri":101,"view_count":89},"2024年5月","\u002Farchive\u002F2024\u002F5\u002F1",{"title":103,"uri":104,"view_count":89},"2024年4月","\u002Farchive\u002F2024\u002F4\u002F1",{"title":106,"uri":107,"view_count":108},"2023年12月","\u002Farchive\u002F2023\u002F12\u002F1","[6]",{"title":110,"uri":111,"view_count":112},"2023年11月","\u002Farchive\u002F2023\u002F11\u002F1","[2]",{"title":114,"uri":115,"view_count":89},"2023年10月","\u002Farchive\u002F2023\u002F10\u002F1",{"title":117,"uri":118,"view_count":89},"2023年7月","\u002Farchive\u002F2023\u002F7\u002F1",{"title":120,"uri":121,"view_count":112},"2023年6月","\u002Farchive\u002F2023\u002F6\u002F1",{"title":123,"uri":124,"view_count":125},"2023年5月","\u002Farchive\u002F2023\u002F5\u002F1","[3]",{"title":127,"uri":128,"view_count":112},"2023年4月","\u002Farchive\u002F2023\u002F4\u002F1",{"title":130,"uri":131,"view_count":112},"2023年3月","\u002Farchive\u002F2023\u002F3\u002F1",{"title":133,"uri":134,"view_count":135},"2023年2月","\u002Farchive\u002F2023\u002F2\u002F1","[5]",{"title":137,"uri":138,"view_count":89},"2023年1月","\u002Farchive\u002F2023\u002F1\u002F1",{"title":140,"uri":141,"view_count":112},"2022年12月","\u002Farchive\u002F2022\u002F12\u002F1",{"title":143,"uri":144,"view_count":135},"2022年11月","\u002Farchive\u002F2022\u002F11\u002F1",{"title":146,"uri":147,"view_count":148},"2022年10月","\u002Farchive\u002F2022\u002F10\u002F1","[4]",{"title":150,"uri":151,"view_count":108},"2022年9月","\u002Farchive\u002F2022\u002F9\u002F1",{"title":153,"uri":154,"view_count":135},"2022年8月","\u002Farchive\u002F2022\u002F8\u002F1",{"title":156,"uri":157,"view_count":89},"2019年7月","\u002Farchive\u002F2019\u002F7\u002F1",{"title":159,"uri":160,"view_count":89},"2019年2月","\u002Farchive\u002F2019\u002F2\u002F1",{"title":162,"uri":163,"view_count":89},"2018年9月","\u002Farchive\u002F2018\u002F9\u002F1",{"title":165,"uri":166,"view_count":89},"2018年8月","\u002Farchive\u002F2018\u002F8\u002F1",{"title":168,"uri":169,"view_count":89},"2017年11月","\u002Farchive\u002F2017\u002F11\u002F1",{"title":171,"uri":172,"view_count":89},"2017年8月","\u002Farchive\u002F2017\u002F8\u002F1",{"title":174,"uri":175,"view_count":89},"2017年5月","\u002Farchive\u002F2017\u002F5\u002F1",{"title":177,"uri":178,"view_count":89},"2017年4月","\u002Farchive\u002F2017\u002F4\u002F1",{"title":180,"uri":181,"view_count":89},"2016年11月","\u002Farchive\u002F2016\u002F11\u002F1",{"title":183,"uri":184,"view_count":89},"2016年10月","\u002Farchive\u002F2016\u002F10\u002F1",{"title":186,"uri":187,"view_count":112},"2016年9月","\u002Farchive\u002F2016\u002F9\u002F1",{"title":189,"uri":190,"view_count":89},"2016年8月","\u002Farchive\u002F2016\u002F8\u002F1",{"title":192,"uri":193,"view_count":112},"2016年7月","\u002Farchive\u002F2016\u002F7\u002F1",{"title":195,"uri":196,"view_count":135},"2016年6月","\u002Farchive\u002F2016\u002F6\u002F1",{"title":198,"uri":199,"view_count":89},"2015年12月","\u002Farchive\u002F2015\u002F12\u002F1",{"title":201,"uri":202,"view_count":89},"2015年10月","\u002Farchive\u002F2015\u002F10\u002F1",{"title":204,"uri":205,"view_count":112},"2015年2月","\u002Farchive\u002F2015\u002F2\u002F1",{"title":207,"uri":208,"view_count":89},"2015年1月","\u002Farchive\u002F2015\u002F1\u002F1",{"title":210,"uri":211,"view_count":212},"2014年12月","\u002Farchive\u002F2014\u002F12\u002F1","[8]",{"title":214,"uri":215,"view_count":112},"2014年11月","\u002Farchive\u002F2014\u002F11\u002F1",{"title":217,"uri":218,"view_count":135},"2014年10月","\u002Farchive\u002F2014\u002F10\u002F1",{"title":220,"uri":221,"view_count":125},"2014年9月","\u002Farchive\u002F2014\u002F9\u002F1",{"title":223,"uri":224,"view_count":125},"2014年8月","\u002Farchive\u002F2014\u002F8\u002F1",{"title":226,"uri":227,"view_count":125},"2014年7月","\u002Farchive\u002F2014\u002F7\u002F1",{"title":229,"uri":230,"view_count":112},"2013年9月","\u002Farchive\u002F2013\u002F9\u002F1",2,{"url":233,"title":234},"https:\u002F\u002Fimage.duguying.net\u002F2022\u002F09\u002Fij6x8o4s.webp","老家 摄于2020年秋",1790781590570]