// Use Google's device oauth endpoint to ask user to enter a code on another device
var response = JSON.parse(http.request("https://accounts.google.com/o/oauth2/device/code", {
postdata: {
client_id: CLIENT_ID,
scope: 'https://www.googleapis.com/auth/youtube'
}
}));
// Create a popup
// We do this manually using properties because we want to wait for event asyncronously
popup = prop.createRoot();
popup.type = 'message';
prop.setRichStr(popup, 'message',
'To give Movian access to your Youtube account,\n' +
'open a web browser on your computer or smartphone and visit:\n\n<font size="6">' +
response.verification_url +
'</font>\n\nWhen asked, enter the code:\n\n<font size="7">' +
response.user_code +
'</font>\n\nThis popup will close automatically once the authentication is completed.');
popup.cancel = true; // Show the cancel button