marco-land / sanity-plugin-vimeo-field

Retrieve Vimeo video data via the API with an access token and store it in Sanity.
MIT License
11 stars 1 forks source link

Can't get it to work #7

Closed opr-inzn closed 1 month ago

opr-inzn commented 2 months ago

So I've added a token to my .env.local as described here: https://github.com/marco-land/sanity-plugin-vimeo-field/issues/6 and in sanity.config I have:

vimeoField({
      accessToken: process.env.SANITY_STUDIO_VIMEO_ACCESS_TOKEN,
    }),

however, the vimeo field still shows No SANITY_STUDIO_VIMEO_ACCESS_TOKEN found! What is my mistake?

marco-land commented 2 months ago

Hi @opr-inzn

Can you share more details of your sanity.config?

Just asking two obvious questions: 1) Did you add it to the plugins array?

export default defineConfig({
  // ...
  plugins: [
    // ...
    vimeoField({
      accessToken: process.env.SANITY_STUDIO_VIMEO_ACCESS_TOKEN,
    }),
  ],
})

2) The env is named SANITY_STUDIO_VIMEO_ACCESS_TOKEN, right? Did you restart the server after adding the env?

If it is still not working: What Sanity version are you on?

opr-inzn commented 2 months ago

Hey @marco-land! This is my sanity.config

plugins: [
    structureTool({ structure }),
    // Vision is for querying with GROQ from inside the Studio
    // https://www.sanity.io/docs/the-vision-plugin
    process.env.NODE_ENV === 'development' && visionTool({ defaultApiVersion: apiVersion }),
    media(),
    vimeoField({
      accessToken: process.env.SANITY_STUDIO_VIMEO_ACCESS_TOKEN,
    }),
  ].filter(Boolean) as PluginOptions[],

It is saved as SANITY_STUDIO_VIMEO_ACCESS_TOKEN in my env.local as well! In Sanity, it shows up like this:

IMG_4749

I‘m on Sanity 3.54. Generating the token happens on developer.vimeo.com, right? Hope we can figure it out!

opr-inzn commented 2 months ago

Do I need a paid account for this to work maybe?

marco-land commented 2 months ago

Do I need a paid account for this to work maybe?

Yes, you definitely need a paid account since Vimeo won't give you access to the direct video files with a free account. But the plugin should have still been able to access your api key from the .env file.

marcobarbosa commented 1 month ago

I have the same issue. There's not much to share here since I followed the instructions just like @opr-inzn. When I do console.log in the sanity.config, the env variable shows up correctly. But for some reason the plugin won't pick it up?

Sanity version ^3.55.0

marco-land commented 1 month ago

It is hard to debug / help without seeing any of your settings. Could you share your sanity config?

Meanwhile, I've just tested with sanity@3.57.3, also with sanity@3.55.0 and sanity-plugin-vimeo-field@1.0.1 and have no issues…

Here's the setup: .env in sanity root -- I've tested with .env and not .env.local

SANITY_STUDIO_VIMEO_ACCESS_TOKEN="YOUR_TOKEN"

Make sure the var SANITY_STUDIO_VIMEO_ACCESS_TOKEN is spelled correct.

sanity.config.ts

export default defineConfig({
  // … your other settings
  plugins: [
    vimeoField({
      accessToken: process.env.SANITY_STUDIO_VIMEO_ACCESS_TOKEN,
    }),
  ],
})

@opr-inzn did you still have issues?

opr-inzn commented 1 month ago

Hey @marco-land, yes, I couldn't get it to work. Is it possible our issues are related to Embedded Studio in NextJS? I have sent an invitation to a demo repo for you to check out with my .env files.

marco-land commented 1 month ago

Hey @marco-land, yes, I couldn't get it to work. Is it possible our issues are related to Embedded Studio in NextJS? I have sent an invitation to a demo repo for you to check out with my .env files.

Thanks for the invite, that was helpful.

In deed, it is a Embedded Studio Problem with NextJS in your case. I've sent you a PR that hopefully works now.

In general, the plugin will move on from using environmental variables to using sanity studio secrets as suggested here https://github.com/marco-land/sanity-plugin-vimeo-field/issues/1 -- I hope to get that in asap…

@marcobarbosa Are you also using a embedded studio (with NextJS) by any chance?

opr-inzn commented 1 month ago

Thanks Marco, that's working now for me!

marcobarbosa commented 1 month ago

Hey @marco-land, yes, I couldn't get it to work. Is it possible our issues are related to Embedded Studio in NextJS? I have sent an invitation to a demo repo for you to check out with my .env files.

Thanks for the invite, that was helpful.

In deed, it is a Embedded Studio Problem with NextJS in your case. I've sent you a PR that hopefully works now.

In general, the plugin will move on from using environmental variables to using sanity studio secrets as suggested here #1 -- I hope to get that in asap…

@marcobarbosa Are you also using a embedded studio (with NextJS) by any chance?

@marco-land Yes, embedded studio here too :)