首页> 软件配置及服务 >软件配置 >其它软件配置 其它软件配置
Google一站式登录网站登录(JavaScript SDK)
作者:小萝卜 2019-06-05 【 第三方登录 Google 功能 】 浏览 3636
简介Google一站式登录网站登录(JavaScript SDK)官网:https://developers.google.com/identity/sign-in/web/一、创建应用a、去谷歌控制台创建应用
Google第三方网站登录(JavaScript SDK)
官网:https://developers.google.com/identity/sign-in/web/
一、创建应用
a、去谷歌控制台创建应用
网址:https://accounts.google.com/signin/v2/identifier?service=cloudconsole&passive=1209600&osid=1&continue=https%3A%2F%2Fconsole.developers.google.com%2Fproject%2F_%2Fapiui%2Fapis%2Flibrary%3Fref%3Dhttps%3A%2F%2Fblog.csdn.net%2Fzh_rey%2Farticle%2Fdetails%2F79013290&followup=https%3A%2F%2Fconsole.developers.google.com%2Fproject%2F_%2Fapiui%2Fapis%2Flibrary%3Fref%3Dhttps%3A%2F%2Fblog.csdn.net%2Fzh_rey%2Farticle%2Fdetails%2F79013290&flowName=GlifWebSignIn&flowEntry=ServiceLogin
b、应用配置如图所示
点击菜单按钮-->API和服务-->证书-->鼠标右键VantageFX Web客户端 做如下配置
1)、授权的jacasvript起源 : 一般是网址
2)、授权重定向url :当前页面的url
二、自定义登录和注销
< button id="customBtn" type="button">Google登录< /button>
< button onclick="signOut();" type="button">Sign out< /button>
< script src="https://apis.google.com/js/api:client.js">< /script>
var googleUser = {};
var startApp = function() {
gapi.load('auth2', function() {
auth2 = gapi.auth2.init({
client_id: 'xxxx', //客户端ID
cookiepolicy: 'single_host_origin',
scope: 'profile' //可以请求除了默认的'profile' and 'email'之外的数据
});
attachSignin(document.getElementById('customBtn'));
});
};
function attachSignin(element) {
auth2.attachClickHandler(element, {},
function(googleUser) {
var profile = auth2.currentUser.get().getBasicProfile();
console.log('ID: ' + profile.getId());
console.log('Full Name: ' + profile.getName());
console.log('Given Name: ' + profile.getGivenName());
console.log('Family Name: ' + profile.getFamilyName());
console.log('Image URL: ' + profile.getImageUrl());
console.log('Email: ' + profile.getEmail());
},
function(error) {
console.log(JSON.stringify(error, undefined, 2));
});
}
startApp();
//注销
function signOut() {
var auth2 = gapi.auth2.getAuthInstance();
auth2.signOut().then(function() {
alert('用户注销成功');
});
}
很赞哦! (0)
相关文章
- OneinStack脚本Let's Encpty SSL证书未能自动续约解决办法
- Navicat15破解版安装教程
- windows服务器下PHP线程安全和非线程安全的区别
- 在Godday上重新生成SSL密钥
- oneinstack——SSL证书更新
- 我的drupal7.56版本在装views的时候,复选框成灰色,不可用
- composer切换国内或国外源
- 网站迁移,需要改下论坛的数据库信息!
- 微信扫描二维码下载apk,显示空白页
- index.html:505 WebSocket connection to 'ws://39.114.25.114:8282/' failed: Error in connection establ