@@ -687,31 +687,49 @@ function google($q, $http, $cordovaOauthUtility) {
687
687
688
688
if ( $cordovaOauthUtility . isInAppBrowserInstalled ( ) ) {
689
689
690
- var redirect_uri , clear_cache , clear_session , approval_prompt , prompt , login_hint ;
690
+ var redirect_uri = 'http://localhost/callback' ,
691
+ clear_cache = 'no' ,
692
+ clear_session = 'no' ,
693
+ prompt_options = [ ] ,
694
+ login_hint ;
691
695
692
- options = options || { } ;
693
-
694
- redirect_uri = options . redirect_uri || "http://localhost/callback" ;
695
- clear_cache = options . clear_cache === true ? 'yes' : 'no' ;
696
- clear_session = options . clear_session === true ? 'yes' : 'no' ;
697
- approval_prompt = options . approval_prompt === true ? 'force' : 'auto' ;
698
- prompt = options . prompt === true ? 'select_account' : 'consent select_account' ;
699
- login_hint = options . login_hint || '' ;
696
+ if ( options !== undefined ) {
697
+ if ( options . hasOwnProperty ( "redirect_uri" ) ) {
698
+ redirect_uri = options . redirect_uri ;
699
+ }
700
+ if ( options . hasOwnProperty ( "clear_cache" ) ) {
701
+ clear_cache = options . clear_cache === true ? 'yes' : 'no' ;
702
+ }
703
+ if ( options . hasOwnProperty ( "clear_session" ) ) {
704
+ clear_session = options . clear_session === true ? 'yes' : 'no' ;
705
+ }
706
+ if ( options . hasOwnProperty ( "prompt" ) ) {
707
+ if ( options . prompt === true ) prompt_options . push ( 'select_account' ) ;
708
+ }
709
+ if ( options . hasOwnProperty ( "consent" ) ) {
710
+ if ( options . consent === true ) prompt_options . push ( 'consent' ) ;
711
+ }
712
+ if ( options . hasOwnProperty ( "login_hint" ) ) {
713
+ login_hint = options . login_hint ;
714
+ }
715
+ }
700
716
717
+ if ( prompt_options . length === 0 ) prompt_options . push ( 'none' ) ;
701
718
702
719
var browserRef = window . cordova . InAppBrowser . open (
703
- 'https://accounts.google.com/o/oauth2/auth?client_id=' + clientId
704
- + '&redirect_uri =' + redirect_uri
705
- + '&scope =' + appScope . join ( " " )
706
- + '&approval_prompt =' + approval_prompt
720
+ 'https://accounts.google.com/o/oauth2/auth?'
721
+ + 'client_id =' + clientId
722
+ + '&redirect_uri =' + redirect_uri
723
+ + '&scope =' + appScope . join ( " " )
707
724
+ '&response_type=token'
708
- + '&prompt=' + prompt
709
- + '&login_hint=' + login_hint
725
+ + '&prompt=' + prompt_options . join ( " " )
726
+ + '&login_hint=' + login_hint
710
727
711
728
, '_blank'
712
729
713
- , 'location=no,clearsessioncache=' + clear_session
714
- + ',clearcache=' + clear_cache
730
+ , 'location=no'
731
+ + ',clearsessioncache=' + clear_session
732
+ + ',clearcache=' + clear_cache
715
733
) ;
716
734
717
735
browserRef . addEventListener ( "loadstart" , function ( event ) {
0 commit comments