Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Popup blocking the gdrive authorization in chrome

So, the problem is that popup blocking the window open even if it is done by a user action, click for example..

gapi.auth.authorize({
   client_id: this.client_id,
   scope: this.scopes,
   access_type: 'online',
   immediate: immediate
}, function(authResult) {
   console.log(authResult)
});

If i simply open the window on user click as here:

$('.some').click(funciton(){
    window.open(someurl)
})

it works fine, but if i did it throw the gdrive api(gapi.auth.authorize), this blocking anyway.

A must, I can not force users to off popap blocking. I hope that anybody now how solved it :), thanks

like image 251
nikitka Avatar asked Dec 15 '22 12:12

nikitka


1 Answers

Try this:

Include an onload event in your call to client.js

<script type="text/javascript" src="https://apis.google.com/js/client.js?onload=handleClientLoad"></script>

Call gapi.auth.init from the onload function:

function handleClientLoad() { window.setTimeout(gapi.auth.init,1); }

In your authorize configuration set immediate: false.

Check that 1. is below 2. in the flow of the page.

like image 96
Ben Eliott Avatar answered Dec 29 '22 00:12

Ben Eliott