2017-08-03 2 views
1

ログインユーザーが特定の組織に属しているかどうかを確認しようとしています。Googleログイン - ユーザーが特定の組織に所属していることを確認します。

組織は、GSuite組織を意味します。たとえば、私が働く会社はXYZです。ユーザーXがその組織内にいるかどうかを確認したいと考えています。

私はGoogle Sign Inの文書に従っており、基本的なユーザーの詳細を取得するための魅力があります。

<head> 
 
    <title>Pricing</title> 
 
    <meta name="google-signin-client_id" content="<Client ID>"> 
 
</head> 
 

 
<body> 
 
    <div class="g-signin2" data-onsuccess="onSignIn"></div> 
 
    <a href="#" onclick="signOut();">Sign out</a> 
 
    <script src="https://apis.google.com/js/platform.js" async defer></script> 
 
    <script> 
 
    function onSignIn(googleUser) { 
 
     var profile = googleUser.getBasicProfile(); 
 
     console.log('Name: ' + profile.getName()); 
 

 
     /* 
 
     At this point, I want to check if the user belongs to a specific GSuite organisation 
 
     */ 
 
    } 
 

 
    function signOut() { 
 
     var auth2 = gapi.auth2.getAuthInstance(); 
 
     auth2.signOut().then(function() { 
 
     console.log('User signed out.'); 
 
     }); 
 
    } 
 
    </script> 
 
</body>

+0

「私はここにいる」 - GSuiteのメンバーシップはどこで確認していますか?あなたはちょうど何かを実際に何もしないコメントを持っているように見えます –

答えて

1

私は、ユーザーの電子メールを照会して、そのメールアドレスのドメインをチェックすることをお勧め:私は最大だのはここ

です。

function onSignIn(googleUser) { 
    console.log('Email: ' + profile.getEmail()); // This is null if the 'email' scope is not present. 
} 
関連する問題