Авторизация через Гугл аккаунт

https://console.developers.google.com/apis/credentials

----------------

<script async defer src="https://apis.google.com/js/api.js"       onload="this.onload=function(){};handleClientLoad()"       onreadystatechange="if (this.readyState === 'complete') this.onload()">     </script> ?>
-----------
// Enter an API key from the Google API Console:
//   https://console.developers.google.com/apis/credentials
var apiKey = '**********';
// Enter the API Discovery Docs that describes the APIs you want to
// access. In this example, we are accessing the People API, so we load
// Discovery Doc found here: https://developers.google.com/people/api/rest/
var discoveryDocs = ["https://people.googleapis.com/$discovery/rest?version=v1"];
// Enter a client ID for a web application from the Google API Console:
//   https://console.developers.google.com/apis/credentials?project=_
// In your API Console project, add a JavaScript origin that corresponds
//   to the domain where you will be running the script.
var clientId = '**************.apps.googleusercontent.com';
// Enter one or more authorization scopes. Refer to the documentation for
// the API or https://developers.google.com/people/v1/how-tos/authorizing
// for details.
var scopes = 'profile';
var authorizeButton = document.getElementById('authorize-button');
var signoutButton = document.getElementById('signout-button');
function handleClientLoad() {
    // Load the API client and auth2 library
    gapi.load('client:auth2', initClient);
}
function initClient() {
    gapi.client.init({
        apiKey: apiKey,
        discoveryDocs: discoveryDocs,
        clientId: clientId,
        scope: scopes
    }).then(function () {
        // Listen for sign-in state changes.
        gapi.auth2.getAuthInstance().isSignedIn.listen(updateSigninStatus);
        // Handle the initial sign-in state.
        updateSigninStatus(gapi.auth2.getAuthInstance().isSignedIn.get());
    });
}
function updateSigninStatus(isSignedIn) {
    if (isSignedIn) {
        makeApiCall();        
    } else {
        vm.showModal = true;
    }
}
function handleAuthClick(event) {
    gapi.auth2.getAuthInstance().signIn();
}
function handleSignoutClick(event) {
    gapi.auth2.getAuthInstance().signOut();
}
// Load the API and make an API call.  Display the results on the screen.
function makeApiCall() {
    gapi.client.people.people.get({
        'resourceName': 'people/me',
        'requestMask.includeField': 'person.names'
    }).then(function (resp) {
        vm.showModal = false;
        vm.loader = false;
        vm.user_id = resp.result.names[0].metadata.source.id;        
        vm.refresh();
    });
}


Комментарии

  1. Did you realize there is a 12 word phrase you can communicate to your man... that will trigger intense emotions of love and impulsive attractiveness to you deep within his heart?

    That's because deep inside these 12 words is a "secret signal" that fuels a man's impulse to love, please and guard you with his entire heart...

    ===> 12 Words Will Fuel A Man's Love Instinct

    This impulse is so hardwired into a man's brain that it will drive him to work harder than before to make your relationship the best part of both of your lives.

    In fact, fueling this mighty impulse is so mandatory to getting the best possible relationship with your man that the second you send your man a "Secret Signal"...

    ...You will instantly notice him expose his heart and soul for you in such a way he never experienced before and he'll see you as the only woman in the world who has ever truly appealed to him.

    ОтветитьУдалить

Отправить комментарий

Популярные сообщения из этого блога

Пишем логи на C# (.NET). Легкий способ.

Учебник yii2