반환된 사용자 인증 정보 응답을 처리하도록 data-callback 속성에 JavaScript 함수를 설정할 수 있습니다. 다음 코드 스니펫을 참조하세요.
<divid="g_id_onload"data-client_id="YOUR_GOOGLE_CLIENT_ID"data-callback="handleCredentialResponse">
</div>
<script>
functionhandleCredentialResponse(response){// decodeJwtResponse() is a custom function defined by you// to decode the credential response.constresponsePayload=decodeJwtResponse(response.credential);console.log("ID: "+responsePayload.sub);console.log('Full Name: '+responsePayload.name);console.log('Given Name: '+responsePayload.given_name);console.log('Family Name: '+responsePayload.family_name);console.log("Image URL: "+responsePayload.picture);console.log("Email: "+responsePayload.email);}
</script>
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2024-11-08(UTC)"],[[["Google Identity Services allows customization of the default login flow to fit specific needs."],["Customization can be achieved using JavaScript in conjunction with the HTML API, particularly by handling the credential response with a callback function."],["Developers need to decode the JWT credential and verify the Google ID token on the server side for security."],["The `data-callback` attribute enables custom handling of user credentials, while avoiding simultaneous use with the `data-login_uri` attribute."]]],[]]