admin管理员组文章数量:1314320
The Google Sign-in platform can be forced to use the new FedCM APIs by setting use_fedcm
to true
when initializing the library, according to
Typically, initialization looks like:
gapi.client.init({use_fedcm: true})
, orgapi.auth2.init({use_fedcm: true})
, orgapi.auth2.authorize({use_fedcm: true})
.
My webapp uses the library, but does not initialize it with any such calls:
<head>
<meta name="google-signin-client_id" content="MY-CLIENT-ID">
<meta name="google-signin-hosted_domain" content="MY-DOMAIN">
<script src=".js" async defer></script>
<script>
function onSignIn(googleUser) {
console.print("id_token=", googleUser.getAuthResponse().id_token);
}
</script>
</head>
<body>
<div class="g-signin2" data-onsuccess="onSignIn"></div>
</body>
How can I set use_fedcm
The Google Sign-in platform can be forced to use the new FedCM APIs by setting use_fedcm
to true
when initializing the library, according to
https://developers.google/identity/sign-in/web/gsi-with-fedcm#conduct_an_impact_assessment
Typically, initialization looks like:
gapi.client.init({use_fedcm: true})
, orgapi.auth2.init({use_fedcm: true})
, orgapi.auth2.authorize({use_fedcm: true})
.
My webapp uses the library, but does not initialize it with any such calls:
<head>
<meta name="google-signin-client_id" content="MY-CLIENT-ID">
<meta name="google-signin-hosted_domain" content="MY-DOMAIN">
<script src="https://apis.google/js/platform.js" async defer></script>
<script>
function onSignIn(googleUser) {
console.print("id_token=", googleUser.getAuthResponse().id_token);
}
</script>
</head>
<body>
<div class="g-signin2" data-onsuccess="onSignIn"></div>
</body>
How can I set use_fedcm
1 Answer
Reset to default 1The gapi.auth2.init(params)
method accepts in addition to use_fedcm
the client_id
and hosted_domain
which are passed as google-signin-client_id
and google-signin-hosted_domain
in the <head>
of the page. We can assume that similarly it works to set google-signin-use_fedcm
.
<meta name="google-signin-use_fedcm" content="true">
https://developers.google/identity/sign-in/web/reference#gapiauth2initparams
We know this has an effect because if we init gapi.auth2 like this, it works fine:
<script src="https://apis.google/js/platform.js?onload=init" async defer></script>
<script>
function init() {
console.log("init was here");
gapi.load('auth2', function() {
// gapi.auth2 has been loaded successfully.
gapi.auth2.init({
client_id: '{{.ClientId}}',
hosted_domain: '{{.Domain}}',
scope: 'profile email',
use_fedcm: true
});
console.log("init was here2");
});
}
</script>
.. whereas setting use_fedcm: false
fails with an exception: "gapi.auth2.ExternallyVisibleError: gapi.auth2 has been initialized with different options"
本文标签:
版权声明:本文标题:fedcm - How to set `use_fedcm` when using the Google Sign-in platform library without any concrete init call - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741909329a2404345.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论