@@ -171,22 +171,24 @@ export class AppManagementClient implements DeveloperPlatformClient {
171171 throw new Error ( 'AppManagementClient.session() should not be invoked dynamically in a unit test' )
172172 }
173173
174- const { appToken , userId , businessPlatformToken } = await ensureAuthenticatedAppManagementAndBusinessPlatform ( )
175- const userAccount = await businessPlatformRequestDoc ( UserInfo , businessPlatformToken )
174+ const tokenResult = await ensureAuthenticatedAppManagementAndBusinessPlatform ( )
175+ const { appManagementToken , businessPlatformToken , userId } = tokenResult
176176
177- if ( userAccount . currentUserAccount ) {
177+ const userInfoResult = await businessPlatformRequestDoc ( UserInfo , businessPlatformToken )
178+
179+ if ( userInfoResult . currentUserAccount ) {
178180 this . _session = {
179- token : appToken ,
181+ token : appManagementToken ,
180182 businessPlatformToken,
181183 accountInfo : {
182184 type : 'UserAccount' ,
183- email : userAccount . currentUserAccount . email ,
185+ email : userInfoResult . currentUserAccount . email ,
184186 } ,
185187 userId,
186188 }
187189 } else {
188190 this . _session = {
189- token : appToken ,
191+ token : appManagementToken ,
190192 businessPlatformToken,
191193 accountInfo : {
192194 type : 'UnknownAccount' ,
@@ -207,15 +209,10 @@ export class AppManagementClient implements DeveloperPlatformClient {
207209 }
208210
209211 async refreshToken ( ) : Promise < string > {
210- const { appToken, businessPlatformToken} = await ensureAuthenticatedAppManagementAndBusinessPlatform (
211- [ ] ,
212- [ ] ,
213- process . env ,
214- { noPrompt : true } ,
215- )
212+ const result = await ensureAuthenticatedAppManagementAndBusinessPlatform ( { noPrompt : true } )
216213 const session = await this . session ( )
217- session . token = appToken
218- session . businessPlatformToken = businessPlatformToken
214+ session . token = result . appManagementToken
215+ session . businessPlatformToken = result . businessPlatformToken
219216
220217 return session . token
221218 }
0 commit comments