@@ -32,15 +32,15 @@ class DataManagementClient {
3232 * @throws Error when the request fails, for example, due to insufficient rights, or incorrect scopes.
3333 */
3434 async * buckets ( page = 16 ) {
35- let access_token = await this . auth . authenticate ( ReadTokenScopes ) ;
36- let response = await get ( `${ RootPath } /buckets?limit=${ page } ` , { 'Authorization' : 'Bearer ' + access_token } ) ;
35+ let authentication = await this . auth . authenticate ( ReadTokenScopes ) ;
36+ let response = await get ( `${ RootPath } /buckets?limit=${ page } ` , { 'Authorization' : 'Bearer ' + authentication . access_token } ) ;
3737 yield response . items ;
3838
3939 while ( response . next ) {
4040 const next = new URL ( response . next ) ;
4141 const startAt = querystring . escape ( next . searchParams . get ( 'startAt' ) ) ;
42- access_token = await this . auth . authenticate ( ReadTokenScopes ) ;
43- response = await get ( `${ RootPath } /buckets?startAt=${ startAt } &limit=${ page } ` , { 'Authorization' : 'Bearer ' + access_token } ) ;
42+ authentication = await this . auth . authenticate ( ReadTokenScopes ) ;
43+ response = await get ( `${ RootPath } /buckets?startAt=${ startAt } &limit=${ page } ` , { 'Authorization' : 'Bearer ' + authentication . access_token } ) ;
4444 yield response . items ;
4545 }
4646 }
@@ -56,8 +56,8 @@ class DataManagementClient {
5656 * with this name does not exist.
5757 */
5858 async bucketDetails ( bucket ) {
59- const access_token = await this . auth . authenticate ( ReadTokenScopes ) ;
60- const response = await get ( `${ RootPath } /buckets/${ bucket } /details` , { 'Authorization' : 'Bearer ' + access_token } ) ;
59+ const authentication = await this . auth . authenticate ( ReadTokenScopes ) ;
60+ const response = await get ( `${ RootPath } /buckets/${ bucket } /details` , { 'Authorization' : 'Bearer ' + authentication . access_token } ) ;
6161 return response ;
6262 }
6363
@@ -73,12 +73,12 @@ class DataManagementClient {
7373 * or when a bucket with this name already exists.
7474 */
7575 async createBucket ( bucket , dataRetention ) {
76- const access_token = await this . auth . authenticate ( WriteTokenScopes ) ;
76+ const authentication = await this . auth . authenticate ( WriteTokenScopes ) ;
7777 const params = {
7878 bucketKey : bucket ,
7979 policyKey : dataRetention
8080 } ;
81- const response = await post ( `${ RootPath } /buckets` , { json : params } , { 'Authorization' : 'Bearer ' + access_token } ) ;
81+ const response = await post ( `${ RootPath } /buckets` , { json : params } , { 'Authorization' : 'Bearer ' + authentication . access_token } ) ;
8282 return response ;
8383 }
8484
@@ -95,14 +95,15 @@ class DataManagementClient {
9595 * @throws Error when the request fails, for example, due to insufficient rights, or incorrect scopes.
9696 */
9797 async * objects ( bucket , page = 16 ) {
98- const access_token = await this . auth . authenticate ( ReadTokenScopes ) ;
99- let response = await get ( `${ RootPath } /buckets/${ bucket } /objects?limit=${ page } ` , { 'Authorization' : 'Bearer ' + access_token } ) ;
98+ let authentication = await this . auth . authenticate ( ReadTokenScopes ) ;
99+ let response = await get ( `${ RootPath } /buckets/${ bucket } /objects?limit=${ page } ` , { 'Authorization' : 'Bearer ' + authentication . access_token } ) ;
100100 yield response . items ;
101101
102102 while ( response . next ) {
103103 const next = new URL ( response . next ) ;
104104 const startAt = querystring . escape ( next . searchParams . get ( 'startAt' ) ) ;
105- response = await get ( `${ RootPath } /buckets/${ bucket } /objects?startAt=${ startAt } &limit=${ page } ` , { 'Authorization' : 'Bearer ' + access_token } ) ;
105+ authentication = await this . auth . authenticate ( ReadTokenScopes ) ;
106+ response = await get ( `${ RootPath } /buckets/${ bucket } /objects?startAt=${ startAt } &limit=${ page } ` , { 'Authorization' : 'Bearer ' + authentication . access_token } ) ;
106107 yield response . items ;
107108 }
108109 }
@@ -121,9 +122,9 @@ class DataManagementClient {
121122 */
122123 async uploadObject ( bucket , name , contentType , data ) {
123124 // TODO: add support for large file uploads using "PUT buckets/:bucketKey/objects/:objectName/resumable"
124- const access_token = await this . auth . authenticate ( WriteTokenScopes ) ;
125+ const authentication = await this . auth . authenticate ( WriteTokenScopes ) ;
125126 const response = await put ( `${ RootPath } /buckets/${ bucket } /objects/${ name } ` , data , {
126- 'Authorization' : 'Bearer ' + access_token ,
127+ 'Authorization' : 'Bearer ' + authentication . access_token ,
127128 'Content-Type' : contentType
128129 } ) ;
129130 return response ;
@@ -139,9 +140,9 @@ class DataManagementClient {
139140 * @throws Error when the request fails, for example, due to insufficient rights, or incorrect scopes.
140141 */
141142 async downloadObject ( bucket , object ) {
142- const access_token = await this . auth . authenticate ( ReadTokenScopes ) ;
143+ const authentication = await this . auth . authenticate ( ReadTokenScopes ) ;
143144 const response = await get ( `${ RootPath } /buckets/${ bucket } /objects/${ object } ` , {
144- 'Authorization' : 'Bearer ' + access_token ,
145+ 'Authorization' : 'Bearer ' + authentication . access_token ,
145146 } , false ) ;
146147 return response ;
147148 }
@@ -158,8 +159,8 @@ class DataManagementClient {
158159 * with this name does not exist.
159160 */
160161 async objectDetails ( bucket , object ) {
161- const access_token = await this . auth . authenticate ( ReadTokenScopes ) ;
162- const response = await get ( `${ RootPath } /buckets/${ bucket } /objects/${ object } /details` , { 'Authorization' : 'Bearer ' + access_token } ) ;
162+ const authentication = await this . auth . authenticate ( ReadTokenScopes ) ;
163+ const response = await get ( `${ RootPath } /buckets/${ bucket } /objects/${ object } /details` , { 'Authorization' : 'Bearer ' + authentication . access_token } ) ;
163164 return response ;
164165 }
165166}
0 commit comments