Home > OS >  GAS: PropertiesService with token is null for PropertiesService
GAS: PropertiesService with token is null for PropertiesService

Time:02-15

What is the correct way to use the OAuth token with Google App Script to use PropertiesService?

I build an application with slack and work well if I don't use this source code.

If I try to use this then result token is null:

const token = PropertiesService.getScriptProperties().getProperty('xoxb-slack-token');
Logger.log(token)
...
Info    null

CodePudding user response:

Apps Script's PropertiesService can be used to store and retrieve data on your script.

If you don't first store them (for example, via setProperty(key,value)), you cannot retrieve them.

So, in this case, you should first get whatever data is coming from Slack and store it as Apps Script properties, if you want to retrieve them later in your script, using this service.

Reference:

  • Related