1
import Ubuntu.OnlineAccounts.Plugin 1.0
4
creationComponent: OAuth {
5
function completeCreation(reply) {
6
console.log("Access token: " + reply.AccessToken)
7
var http = new XMLHttpRequest()
8
var url = "https://www.googleapis.com/oauth2/v3/userinfo";
9
http.open("POST", url, true);
10
http.setRequestHeader("Authorization", "Bearer " + reply.AccessToken)
11
http.onreadystatechange = function() {
12
if (http.readyState === 4){
13
if (http.status == 200) {
15
console.log("response text: " + http.responseText)
16
var response = JSON.parse(http.responseText)
17
account.updateDisplayName(response.email)
18
account.synced.connect(finished)
22
console.log("error: " + http.status)