Cordova InAppBrowser show location bar Cordova AngularJS Oauth -
hi i'm using cordova inappbrowser , angularjs oauth plugins.
when press normal link button this:
<a class="external" ng-href="https://www.website.com/" targe="_blank" >open link</a>
in combination this:
<script> $( document ).ready(function() { // open links in native browser (phonegap); $(document).on('click', '.external', function (event) { event.preventdefault(); window.open($(this).attr('href'), '_blank'); return false; }); }); </script>
it opens link in in app browser. in inappbrowser when loading url showing url location @ bottom. working ok.
when angularjs oauth plugin opens inappbrowser , starts load login page of facebook example doesn't show loading url location @ bottom.
i tried add "location=yes"
in oauth plugin this, still not showing url loading bar @ bottom:
window.open('https://www.website.com/oauth/authorize?client_id=' + clientid + '&redirect_uri=http://localhost/callback&scope=' + appscope.join(",") + '&response_type=code&approval_prompt=force', '_blank', 'location=yes,clearsessioncache=yes,clearcache=yes');
how can force show loading bar oauth in inappbrowser ? reason want when login page needs time load there no loading indication , mind think there nothing happening.
this how oauth function looks location=yes:
strava: function(clientid, clientsecret, appscope) { var deferred = $q.defer(); if(window.cordova) { var cordovametadata = cordova.require("cordova/plugin_list").metadata; if(cordovametadata.hasownproperty("cordova-plugin-inappbrowser") === true || cordovametadata.hasownproperty("org.apache.cordova.inappbrowser") === true) { var browserref = window.open('https://www.strava.com/oauth/authorize?client_id=' + clientid + '&redirect_uri=http://localhost/callback&scope=' + appscope.join(",") + '&response_type=code&approval_prompt=force', '_blank', 'location=yes,clearsessioncache=yes,clearcache=yes'); browserref.addeventlistener('loadstart', function(event) { if((event.url).indexof("http://localhost") === 0) { requesttoken = (event.url).split("code=")[1]; $http.defaults.headers.post['content-type'] = 'application/x-www-form-urlencoded'; $http({method: "post", url: "https://www.strava.com/oauth/token", data: "client_id=" + clientid + "&client_secret=" + clientsecret + "&code=" + requesttoken }) .success(function(data) { deferred.resolve(data); }) .error(function(data, status) { deferred.reject("problem authenticating"); }) .finally(function() { settimeout(function() { browserref.close(); }, 10); }); } }); browserref.addeventlistener('exit', function(event) { deferred.reject("the sign in flow canceled"); }); } else { deferred.reject("could not find inappbrowser plugin"); } } else { deferred.reject("cannot authenticate via web browser"); } return deferred.promise; },
i found solution. app loading oauth plugin twice, once via separate oauth script added project , once via ngcordova library. ngcordova script overruling oauth script added that's why location=yes not working.
i removed separate oauth script , changed location=no yes in ngcordova oauth script.
Comments
Post a Comment