如何获得登录方式?

时间:2019-06-25 09:56:11

标签: google-api google-signin credentials googlesigninapi

我正在尝试关注this

在以下情况下,我得到gSignIn未定义错误, 头上也有<script src="https://apis.google.com/js/platform.js" async defer></script>

我缺少一些API? 如何达到gSignIn方法? 我如何通过js触发singin?

navigator.credentials.get({
    password: true,
    federated: {
        providers: [
            'https://accounts.google.com'
        ]
    },
    mediation: 'required'
}).then(c => {
    if (c) {
        switch (c.type) {
            case 'password':
                return sendRequest(c);
                break;
            case 'federated':
                return gSignIn(c);
                break;
        }
    } else {
        return Promise.resolve();
    }
}).then(profile => {
    if (profile) {
        updateUI(profile);
    }
}).catch(error => {
    console.error('Sign-in Failed');
});

0 个答案:

没有答案