QueryParamToken - Access to the parameter


When we use setUserAuthentication with :
type: coda.AuthenticationType.QueryParamToken,

Is there a way to access the parameter throught the context in a formula?
I have check this but there is nothing about that :

Thank you in advance

For security purposes Coda handles all the authentication, you won’t be able to access the token the user provided.

1 Like

@Leandro_Zubrezki is correct, Pack developer don’t have direct access to user credentials.

@j.b_o - Can you provide more context on why you would need / want to access that value in your Pack code?

@Leandro_Zubrezki @Eric_Koleda Thank you for the quick answers.
I understand well the security purpose.

I’m working on a pack to access to the Plex API.
When i request to the playlists information for example, i get a response like :

	"MediaContainer": {
		"size": 2,
		"Metadata": [
				"title": "Playlist 1",
				"playlistType": "audio",
				"composite": "/path_to_the_playlist_1_cover",
				"title": "Playlist 2",
				"playlistType": "audio",
				"composite": "/path_to_the_playlist_2_cover",

It’s ok with the response and i would like to get the cover into a column (“compose”).
I know i can access to the cover through the url:
endpoint + "/path_to_the_playlist_1_cover?token=" + token

That is the url i try to build…
But as far as i understand, i have to make a second request and try to use the temporaryBlobStorage property, don’t i? :face_with_monocle:

PS :
By the way, actually i stringify the response to explicit the data structure and because i didn’t succeed to access to the data with the formula directly, for exemple:
MyPlaylist("My Plex").Metadata doesn’t work so i use MyPlaylist("My Plex").ParseJSON(Metadata). It’s work but it add a new formula step :person_shrugging:

Yes, the approach here would be to fetch the images in your code, which would apply the user’s credentials, and then store the images in temporary blob storage. You’d want to then return the image as the type ImageAttachment, so that Coda ingests the temporary URL into a more permanent one. Be aware though that this approach will only work within a sync table (see here). If this is in a formula then there isn’t a great way to deal with images that require authentication.

Instead of returning stringified JSON, the better approach would be to return an object defined by a schema (see here).

Thank you very much for the information. I will try it later.
I note the limitation of this approach in a formula.
To bypass the limitation, is there a way to use a sync table which depends of a parameter?

Sync tables can take parameters, but they are usually designed to sync a large number of records, vs targeting single ones.

Thank you @Eric_Koleda.

About the TemporaryBlobStorage, i am not familiar with it.
I try to use storeBlob and storeURL without success:

const compositeurl = endpoint + "" + library.composite;
let responsecover = await context.fetch(compositeurl);
let blob = await responsecover.blob();
let coverurl = storeBlob(blob, {type: 'image/png'},"");

Unfortunately we haven’t written up much documentation on this feature yet, but the code would look like this:

let response = await context.fetcher.fetch({
  method: "GET",
  url: imageUrl,
  isBinaryResponse: true,
let buffer = response.body;
let contentType = response.headers["content-type"] as string;
let tempUrl = await context.temporaryBlobStorage.storeBlob(buffer, contentType);
1 Like

Thank you @Eric_Koleda .
It works perfectly well :wink:

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.