Closed yankustefan closed 9 years ago
@yankustefan I think the premise behind the current implementation is to mimic, as much as possible, Google's auth API. I understand that we will adding helper methods, to serve as syntactic sugar. This may be a use-case for one.
(@pinoyyid, please correct me if I'm of base, and deserve a kick in the head ... :-)
The more I think about it, the more I agree that getAccessToken retuning a promise cleans up a lot of internal code as well as providing more functionality to the app, eg. by providing a notify('refreshing token') which the app can act on. My initial concern was that giving a promise to a newbie might be confusing, but on reflection, newbies are unlikely to be calling getAccessToken themselves anyway.
This has been implemented in the at_promise branch. OuthService,getAccessToken():IPromise<Google GapiAccessTokenObject>
. Will be merged to master in this week.
Hi, I tried the updated nggapi_base.min.js and nggapi_drive.min.js and tested with minimal.html.
I get the following error:
TypeError: Cannot read property 'getToken' of undefined
at a.getAccessToken (nggapi_base.min.js:1)
at a._doHttp (nggapi_base.min.js:1)
at a.dq (nggapi_base.min.js:1)
at nggapi_base.min.js:1
at angular.min.js:114
at n.$get.n.$eval (angular.min.js:126)
at n.$get.n.$digest (angular.min.js:123)
at n.$get.n.$apply (angular.min.js:126)
at angular.min.js:90angular.min.js:102 (anonymous function)angular.min.js:76 $getangular.min.js:114 (anonymous function)angular.min.js:126 $get.n.$evalangular.min.js:123 $get.n.$digestangular.min.js:126 $get.n.$applyangular.min.js:90 (anonymous function)
it looks like the .min.js files weren't rebuilt. I've rebuilt (grunt distlib) and pushed the changes to the at_promise branch
Just a thought:
Currently, OauthService.getAccessToken() returns either the key or something like "!RETRY=500".
Would it make sense to offer a "accessCheck" function to that returns a promise?
That would be great if: