@@ -40,14 +40,13 @@ eg012EmbeddedConsole.createController = async (req, res) => {
40
40
}
41
41
42
42
// Step 2. Call the worker method
43
- let accountId = req . dsAuthCodeGrant . getAccountId ( )
44
- , dsAPIclient = req . dsAuthCodeGrant . getDSApi ( )
45
- , body = req . body
43
+ let body = req . body
46
44
// Additional data validation might also be appropriate
47
45
, startingView = validator . escape ( body . startingView )
48
46
, args = {
49
- dsAPIclient : dsAPIclient ,
50
- accountId : accountId ,
47
+ accessToken : req . user . accessToken ,
48
+ basePath : req . session . basePath ,
49
+ accountId : req . session . accountId ,
51
50
dsReturnUrl : dsReturnUrl ,
52
51
startingView : startingView ,
53
52
envelopeId : req . session . envelopeId // may be undefined
@@ -88,15 +87,16 @@ eg012EmbeddedConsole.createController = async (req, res) => {
88
87
*/
89
88
// ***DS.worker.start ***DS.snippet.1.start
90
89
eg012EmbeddedConsole . worker = async ( args ) => {
91
- let envelopesApi = new docusign . EnvelopesApi ( args . dsAPIclient )
92
- , results = null
93
- ;
90
+ let dsApiClient = new docusign . ApiClient ( ) ;
91
+ dsApiClient . setBasePath ( args . basePath ) ;
92
+ dsApiClient . addDefaultHeader ( 'Authorization' , 'Bearer ' + args . accessToken ) ;
93
+ let envelopesApi = new docusign . EnvelopesApi ( args . dsAPIclient ) ;
94
94
95
95
// Step 1. create the NDSE view
96
96
let viewRequest = makeConsoleViewRequest ( args ) ;
97
97
// Call the CreateSenderView API
98
98
// Exceptions will be caught by the calling function
99
- results = await envelopesApi . createConsoleView (
99
+ let results = await envelopesApi . createConsoleView (
100
100
args . accountId , { consoleViewRequest : viewRequest } ) ;
101
101
let url = results . url ;
102
102
console . log ( `NDSE view URL: ${ url } ` ) ;
0 commit comments