How to trigger click on "Save to Google Drive" button -


how trigger "click" on save google drive button, mean, have own design "save google drive" button. there programaticly trigger open "save google drive" popups in javascript?

thanks

edit

i want modify api

https://developers.google.com/drive/v3/web/savetodrive#getting_started

you can try:

html:

<html> <head> <title>save drive</title> </head> <body> <input type="button" id="doitbutton" value="save chat history in drive">  <input type="button" id="authorizebutton" value="authorize" onclick="checkauth()"> <script type="text/javascript" src="https://apis.google.com/js/client.js?onload=handleclientload"></script> </body> </html> 

js:

var client_id = 'client_id'; var scopes = 'https://www.googleapis.com/auth/drive';  function handleclientload() { window.settimeout(checkauth, 1); }  function checkauth() { gapi.auth.authorize({ 'client_id' : client_id, 'scope' : scopes, 'immediate' : true }, handleauthresult); }  function handleauthresult(authresult) { var authbutton = document.getelementbyid('authorizebutton'); var doitbutton = document.getelementbyid('doitbutton'); authbutton.style.display = 'none'; doitbutton.style.display = 'none'; if (authresult && !authresult.error) { // access token has been retrieved, requests can sent // api. doitbutton.style.display = 'block'; doitbutton.onclick = uploadfile; } else { // no access token retrieved, show button start // authorization flow. authbutton.style.display = 'block'; authbutton.onclick = function() { gapi.auth.authorize({ 'client_id' : client_id, 'scope' : scopes, 'immediate' : false }, handleauthresult); }; } }  function uploadfile(evt) { gapi.client.load('drive', 'v2', function() { insertfile(); }); }  function insertfile() { //your insert code } 

as can see, handleauthresult() oauth result , conditionally check authorization if successful add onclick="uploadfile()".


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo