pinoyyid / ngGAPI

AngularJS library to access Google Drive and other Google APIs the Angular way
GNU Lesser General Public License v2.1
6 stars 3 forks source link

promise based oauth #8

Closed yankustefan closed 9 years ago

yankustefan commented 9 years ago

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:

estilles commented 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 ... :-)

pinoyyid commented 9 years ago

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.

pinoyyid commented 9 years ago

This has been implemented in the at_promise branch. OuthService,getAccessToken():IPromise<Google GapiAccessTokenObject>. Will be merged to master in this week.

yankustefan commented 9 years ago

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)
pinoyyid commented 9 years ago

it looks like the .min.js files weren't rebuilt. I've rebuilt (grunt distlib) and pushed the changes to the at_promise branch