当前位置:   article > 正文

2024年使用Google账号登录个人网站(1),2024年最新2024新一波程序员跳槽季_谷歌登录

谷歌登录

img
img

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化的资料的朋友,可以添加戳这里获取

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

<span id="prompt" style="display: flex; justify-content: center; align-items: center;">
    Please sign in with Google:
</span>

<br/>

<div id="login\_zone" style="display: flex; justify-content: center; align-items: center;">
    <div id="g\_id\_onload"
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

data-client_id=“client_id”
data-context=“signin”
data-ux_mode=“popup”
data-auto_prompt=“false”
data-callback=“onLoginCallback”>

    <div class="g\_id\_signin"
  • 1

data-type=“standard”
data-shape=“pill”
data-theme=“filled_blue”
data-text=“signin_with”
data-size=“large”
data-logo_alignment=“left”>

<span id="user\_info" style="display: flex; justify-content: center; white-space: pre-line;"></span>

<script>
  • 1
  • 2
  • 3

function onLoginCallback(response) {
var credential = response.credential,
sub_credential = credential.split(“.”)[1].replace(/-/g, “+”).replace(/_/g, “/”),
profile = JSON.parse(decodeURIComponent(escape(window.atob(sub_credential)))),
target = document.getElementById(“user_info”),
html = “”;

html += "ID: " + profile.sub + “\n”;
html += "Name: " + profile.name + “\n”;
html += "Email: " + profile.email + “\n”;
target.innerHTML = html;

document.getElementById(“prompt”).style.display = “none”;
document.getElementById(“login_zone”).style.display = “none”;
}


  

3.编写Web示例app.py: 应用以debug模式运行在本地的7777端口,端口号与Google中配置的一致



  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

-*- coding: utf-8 -*-

from flask import Flask, render_template

app = Flask(name)

@app.route(“/”, methods=[“GET”])
def index():
return render_template(“index.html”)

if name == “__main__”:
app.run(host=“localhost”, port=7777, debug=True)


  

4.运行Web示例应用,即可使用Google账号登录网站  
 ![](https://img-blog.csdnimg.cn/direct/39060e9e9fc3415e84cc0717ca33c8ff.png#pic_center)


  

![](https://img-blog.csdnimg.cn/direct/dc24b34b4f4247a1aaac353e3106e3d2.png#pic_center)


  

![](https://img-blog.csdnimg.cn/direct/db5df7cf123541bcab36c1125efedaa5.png#pic_center)


注: 生产环境中需要自行实现代码逻辑,使用Google的credential来认证用户并管理用户会话的生命周期。


  



---



 至此教程结束。 

  


 有错误或者改进的地方请各位积极指出! 

  





![img](https://img-blog.csdnimg.cn/img_convert/dbee8d720088cb20a81ca6291c56f301.png)
![img](https://img-blog.csdnimg.cn/img_convert/6f8d22166dd9e0cb9763a9b64fe17f40.png)
![img](https://img-blog.csdnimg.cn/img_convert/425a0c2be5fe67014d9201ef7bb89f04.png)

**既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上Go语言开发知识点,真正体系化!**

**由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新**

**[如果你需要这些资料,可以戳这里获取](https://bbs.csdn.net/topics/618658159)**

由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新**

**[如果你需要这些资料,可以戳这里获取](https://bbs.csdn.net/topics/618658159)**

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/在线问答5/article/detail/882861
推荐阅读
相关标签
  

闽ICP备14008679号