What's the easiest way to authenticate using JWT in Gol?

blov · · 590 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>I&#39;m newbie to go and developed a REST API in Go withouth framework. Now I want to use Google OAuth2 authentication. I&#39;m wondering what is the most fool-proff way to do so? </p> <hr/>**评论:**<br/><br/>shovelpost: <pre><blockquote> <p>Now I want to use Google OAuth2 authentication.</p> </blockquote> <p>Use <a href="https://godoc.org/golang.org/x/oauth2" rel="nofollow">golang.org/x/oauth2</a>.</p></pre>gar44: <pre><p>Any slow-paced tutorial to use the library? </p></pre>icholy: <pre><p>see <a href="https://godoc.org/golang.org/x/oauth2#example-Config" rel="nofollow">https://godoc.org/golang.org/x/oauth2#example-Config</a></p></pre>gar44: <pre><p>Too cryptic for me. </p></pre>gogroob: <pre><p>Full tutorial from start to finish <a href="https://cloud.google.com/go/getting-started/authenticate-users" rel="nofollow">https://cloud.google.com/go/getting-started/authenticate-users</a></p></pre>gar44: <pre><p>This is for GAE, not useful for me. </p></pre>dobegor: <pre><p>No it&#39;s not for GAE only. You need to create an app and configure it in GCP Console to obtain OAuth credentials.</p></pre>Smokey_Circles: <pre><p><a href="http://lmgtfy.com/?q=How+does+oauth+work" rel="nofollow">here you go</a> </p> <p>You need to internalize oauth better. Both tutorials in this chain are simple enough to get you going in go, but not if you don&#39;t know where you&#39;re going </p></pre>gogroob: <pre><p>the authnetication code is independent of app engine </p></pre>shovelpost: <pre><p>Also try this: <a href="https://medium.com/@cgrant/golang-oauth2-google-example-for-web-and-api-59187ce8b119" rel="nofollow">https://medium.com/@cgrant/golang-oauth2-google-example-for-web-and-api-59187ce8b119</a></p></pre>gar44: <pre><p>This guy just links to another tutorial at <a href="http://skarlso.github.io/2016/06/12/google-signin-with-go/" rel="nofollow">http://skarlso.github.io/2016/06/12/google-signin-with-go/</a> which I tried its github repo and got 500 error. </p></pre>shovelpost: <pre><p>It is very difficult to help you when you do not explain the problem.</p> <p>The medium article I linked has a summary of the code needed to use oauth2 with Go. Did you try it? Did you encounter any problems with it?</p></pre>thomasfr: <pre><p>You should really try learn the basic workings of oauth2 before using it. It&#39;s not that complicated.</p></pre>mcouturier: <pre><p>Some background on oauth2: <a href="https://gist.github.com/mziwisky/10079157" rel="nofollow">https://gist.github.com/mziwisky/10079157</a></p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

590 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传