728x90
구글 버튼 변경(https://developers.google.com/identity/sign-in/web/build-button)
<header>
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet" type="text/css">
<script src="https://apis.google.com/js/api:client.js"></script>
<script> ( 회원가입 로그인 로직 추가 )
<script>
var googleUser = {};
var startApp = function() {
gapi.load('auth2', function(){
// Retrieve the singleton for the GoogleAuth library and set up the client.
auth2 = gapi.auth2.init({
client_id: 'YOUR_CLIENT_ID.apps.googleusercontent.com',
cookiepolicy: 'single_host_origin',
// Request scopes in addition to 'profile' and 'email'
//scope: 'additional_scope'
});
attachSignin(document.getElementById('customBtn'));
});
};
function attachSignin(element) {
console.log(element.id);
auth2.attachClickHandler(element, {},
function(googleUser) {
document.getElementById('name').innerText = "Signed in: " +
//이 부분에 회원가입, 로그인 로직 추가
googleUser.getBasicProfile().getName();
googleUser.getBasicProfile().getId();
googleUser.getBasicProfile().getEmail();
}, function(error) {
alert(JSON.stringify(error, undefined, 2));
});
}
</script>
<script>startApp();</script>
<css>
<style type="text/css">
#customBtn {
display: inline-block;
background: white;
color: #444;
width: 190px;
border-radius: 5px;
border: thin solid #888;
box-shadow: 1px 1px 1px grey;
white-space: nowrap;
}
#customBtn:hover {
cursor: pointer;
}
span.label {
font-family: serif;
font-weight: normal;
}
span.icon {
background: url('/identity/sign-in/g-normal.png') transparent 5px 50% no-repeat;
display: inline-block;
vertical-align: middle;
width: 42px;
height: 42px;
}
span.buttonText {
display: inline-block;
vertical-align: middle;
padding-left: 42px;
padding-right: 42px;
font-size: 14px;
font-weight: bold;
/* Use the Roboto font that is loaded in the <head> */
font-family: 'Roboto', sans-serif;
}
</style>
<jsp>
<div id="gSignInWrapper">
<span class="label">Sign in with:</span>
<div id="customBtn" class="customGPlusSignIn">
<span class="icon"></span>
<span class="buttonText">Google</span>
</div>
</div>
<div id="name"></div>
728x90
반응형
'개발' 카테고리의 다른 글
[localStorage] 로그인 상태 유지 (0) | 2020.08.10 |
---|---|
비밀번호 보기 / 숨기기 기능 구현 (0) | 2020.08.06 |
[javascript] base url 추출 (0) | 2020.07.28 |
[linux] chmod 하위 폴더 권한 적용 (0) | 2020.07.23 |
[javascript] toogle 버튼 만들기 (0) | 2020.07.23 |