Oauth - Template variable not defined
I've gotmy OAuth token in place(.frsh/localstore) and when I try to make my request the <%= access_token %> variable in the headers are recognised.
Here is my code gist along with the error details.
Looks like this issue is similar to an issue raised a while back.
Did you go through the oauth authorization flow? And are there any errors in the console (or) is the token not substituted in the header?
Raghuram, I'm sorry the initial post was not very clear.
I've gone through the OAuth authorisation flow and thus the access_token is available in the .frsh/localstore file.
But then, when I'm trying to use that variable (access_token) in the code, as described in the documentation, I get the following error -
ReferenceError: access_token is not defined at eval (eval at _.template (/usr/local/lib/node_modules/frsh-sdk/node_modules/underscore/underscore.js:1454:20), <anonymous>:6:9) at template (/usr/local/lib/node_modules/frsh-sdk/node_modules/underscore/underscore.js:1461:21) at substituteTemplates (/usr/local/lib/node_modules/frsh-sdk/lib/api/proxy.js:41:59) at Object.execute (/usr/local/lib/node_modules/frsh-sdk/lib/api/proxy.js:20:18) at dpRouterExec (/usr/local/lib/node_modules/frsh-sdk/lib/routes/data-pipe.js:6:32) at Layer.handle [as handle_request] (/usr/local/lib/node_modules/frsh-sdk/node_modules/express/lib/router/layer.js:95:5) at next (/usr/local/lib/node_modules/frsh-sdk/node_modules/express/lib/router/route.js:137:13) at Route.dispatch (/usr/local/lib/node_modules/frsh-sdk/node_modules/express/lib/router/route.js:112:3) at Layer.handle [as handle_request] (/usr/local/lib/node_modules/frsh-sdk/node_modules/express/lib/router/layer.js:95:5) at /usr/local/lib/node_modules/frsh-sdk/node_modules/express/lib/router/index.js:281:22
You can look at the code in the OP. Hope this can be resolved ASAP.
We need some more details to debug the issue.
- SDK version
- Node version
- Oauth provider
The substitution of access_token happens in the server side. We dont let the app read the access_token directly until it is local testing.
Thanks Raghu, Mahesh.
I am now past this. Appreciate your support.