Oauth - Template variable not defined

  • 18 October 2017
  • 5 replies
  • 39 views


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.




https://gist.github.com/PritiKumr/7e725388bf613f4e5fa98106ac419a77




Looks like this issue is similar to an issue raised a while back. 




https://support.freshdesk.com/support/discussions/topics/316814




Thanks,


Preethi






template-var-error_29213.png

This topic has been closed for comments

5 replies


Thanks Raghu, Mahesh. 




I am now past this. Appreciate your support.



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.



Hi Preethi,


 


We need some more details to debug the issue.




  • SDK version 

  • Node version

  • Oauth provider 




Adding to it, make sure you have not modified .frsh/localstore file.



Thanks.



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.





Hi Preethi,




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?




Thanks,


Raghuram. P