Issue encountered with @Nuxt.js/Cloudinary plugin for Media Enhancement: "Access to this endpoint is restricted due to insufficient permissions"

I am currently utilizing the @nuxtjs/cloudinary module based on the module guide and a course video. However, I am encountering an error in the response as follows:

Status 403, message: You don't have sufficient permissions to access this endpoint"

My Cloudinary account is set up with Media Optimizer. The cloud name, API, and Secret keys are correctly configured. Upon further investigation, I discovered that the module is designed for Programmable Media product instead of Media Optimizer which has different API endpoints. Despite referring to the documentation, I was unable to resolve the issue. The course I am following is called Mastering Nuxt.

ImageUploader.vue

<template>
  <div>
    <input type="file" accept=".jpeg,.gpj,image/jpeg" @change="uploadFile" />
  </div>
</template>

<script>
import { unWrap } from "~/utils/fetchUtils";
export default {
  methods: {
    async uploadFile(e) {
      const file = e.target.files[0];

      /* Validate file existence */
      if (!file) return;

      /* Configure cloudinary options object */
      const filename = file.name.split(".").slice(0, -1).join(".") + Date.now();
      const options = { timestamp: Date.now(), public_id: filename };

      /* Create signature */
      const response = await unWrap(
        await fetch("/api/cloudinary/signature", {
          method: "POST",
          headers: {
            "Content-Type": "application/json",
          },
          body: JSON.stringify(options),
        })
      );
      const signature = response.data.signature;

      /* Read data */
      const readData = (fileObj) =>
        new Promise((resolve) => {
          const reader = new FileReader();
          reader.onloadend = () => resolve(reader.result);
          reader.readAsDataURL(fileObj);
        });
      const data = await readData(file);

      /* Upload converted data */
      console.log(signature); // testing
      const asset = await this.$cloudinary.upload(data, {
        ...options,
        apiKey: this.$config.cloudinary.apiKey,
        signature,
      });
    },
  },
};
</script>

nuxt.config

modules: [
  "@nuxtjs/firebase",
  "~/modules/cloudinary",
]

publicRuntimeConfig: {
  cloudinary: {
    apiKey: "399741578529427",
  },
},

privateRuntimeConfig: {
  cloudinary: {
    apiSecret: "<My-Secret-API-Key>",
  },
},

cloudinary: {
  cloudName: "nuxtbnb-m98",
},

modules/cloudinray.js

import { createHash } from "crypto";

export default function () {
  const config = this.options.privateRuntimeConfig.cloudinary;

  this.nuxt.hook("render:setupMiddleware", (app) => {
    app.use("/api/cloudinary/signature", setSignature);
  });

  function setSignature(req, res) {
    try {
      const sha1 = createHash("sha1");
      const payload = [];

      Object.keys(req.body).forEach((key) => {
        payload.push(`${key}=${req.body[key]}`);
      });

      sha1.update(payload.sort().join("&") + config.apiSecret);
      const signature = sha1.digest("hex");

      res.end(
        JSON.stringify({
          signature,
        })
      );
    } catch (error) {
      console.log(error);
    }
  }
}

Answer №1

To upload assets, you must have a Programmable Media account. Since this course requires payment, I am unable to view its content. However, I recommend the following options:

  • Set up a new Programmable Media account using a different email address.
  • Contact [email protected] for assistance in deleting your current account and freeing up your email address.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Error in jQuery submenu positioning issue

I am attempting to design a menu that opens when the parent element is clicked and closes when the mouse leaves the previously opened one. It should operate from left to right. Here is an example: <ul class="menuFirst"> <li><im ...

Exploring JSON data structures using autocomplete functionalities

Here's the code I'm working with: <s:hidden id="s" value="%{Users}"/> The variable Users contains an array list of User objects. This code is written in Javascript. I want to access Users as JSON for auto-complete functionality: var valu ...

Retrieving pals from the API and showcasing them on the user interface

Currently, I am working on a project involving a unique Chat Application. While progressing with the development, I encountered an issue related to fetching friends data from the backend (node). Even though I can successfully retrieve the friends data in ...

Search through the JSON data, identify similar values, and save them in a collection

Struggling to find a way to limit the output of my comparison between attribute values in an object, I am only looking for one output per ID. Any suggestions? //example JSON var obj1 = { "Summary" : [ { "ID" : "1234", "Name" : "Joh ...

Switch the style sheets after the content

How can I create a toggle effect on the :after property, switching between + and - each time the link is clicked? I've attempted to achieve this using JavaScript, CSS, and HTML, but the code only changes + to - and doesn't switch back when the l ...

Having trouble retrieving the ID of a button?

I'm attempting to retrieve the ID of a button, but I seem to be getting the ID of the surrounding div instead. This is not the desired outcome. Here's my current approach: HTML <div class="container container-about container-login"> ...

Utilize the withCredentials property in conjunction with $resource

I am looking to utilize a resource with a cookie set in the navigator. Using $http makes it simple, just need to set withCredentials to true: $http({ method: 'POST', url: url, data: user, withCredentials: true }); However, for ...

Encountering a failure when trying to run npm in a React project

I've removed the .lock file and node_modules, then reinstalled, but it's still not working. Can someone assist me with fixing this? npm ERR! gyp ERR! node -v v16.13.0 npm ERR! gyp ERR! node-gyp -v v8.2.0 npm ERR! gyp ERR! not ok npm ERR! node-pr ...

What is the best way to locate a document's array item in MongoDB (Mongoose) using its "_id" field?

Here is the schema I'm working with using NestJS and Mongoose: @Schema({ timestamps: true }) export class Listing { @Prop({ type: [{ bidderId: { type: Types.ObjectId, required: true, select: false, ref: User.name, index: true }, ...

Searching for a streamlined approach to retrieve a segment of a string

I'm currently working with JavaScript and TypeScript. Within my code, I encountered a scenario where I have a string that might contain certain tags indicating importance or urgency. Here are a couple of examples: A: "Remind me to go to the store to ...

What is the best way to transfer parameters from a Vue custom element to a Vue component?

Due to not having a complete Vue app, I have resorted to using custom elements from vue-custom-element to substitute certain elements that need to be managed with Vue. My goal is simply to incorporate the Vue Multiselect plugin into an HTML file. Here is ...

Filtering JSON Objects in JavaScript: A Comprehensive Guide

I have been attempting to filter the JSON object below and create an array of objects that have a value containing "steve" in the key 'markdown'. My initial approach involves converting the object to an array then applying a filter. Although I h ...

How can I make text wrap instead of overflowing to ellipsis in a list when using vue-material?

Question: <md-list-item> <md-icon v-bind:style="{color: transcript.color}">account_circle</md-icon> <div class="md-list-item-text"> <p>{{ transcript.text }}</p> </di ...

Is there a way to run /_next/static/xxx.js using a script tag?

I have customized my next.config file (webpack) to generate a static JavaScript file (.next/static/loader.js). The original loader.js is an Immediately Invoked Function Expression (IIFE): (function stickerLoader(){ alert('Hello'); // ... so ...

Tips for retrieving the count from HTML using JavaScript:

I need to determine the count of list items in an unordered list within dir-pagination-controls. How can I achieve this using JavaScript? <dir-pagination-controls min-size="1" direction-links="true" boundary-links="true" class="pull-right ng-isolate- ...

Step-by-step guide on concealing elements and subsequently displaying them upon clicking the containing DIV

It's a bit tricky to explain without visuals, so I suggest checking out the JSFiddle link provided. Essentially, when a specific div is clicked, it should expand to reveal some inputs and buttons. However, the issue I'm facing is that upon loadin ...

Exploring ways to run tests on a server REST API using testem

When using Testem, I have a config option called serve_files that handles serving the client-side code for me. However, I also need to run my server because it includes a REST API that the client side relies on. Is there a way to configure Testem to launc ...

The Chrome Extension was denied from loading due to a violation of the specified Content Security Policy

I am encountering an issue while loading a Chrome Extension using React. Whenever I try to load it, the error message below pops up: Refused to load the script 'https://code.jquery.com/jquery-3.2.1.slim.min.js' because it violates the following ...

Controlling the Vuetify Navigation drawer from a separate component

Within my App.vue component, I have a Navigation Drawer menu containing main items and some subitems. These subitems are meant to be displayed only after a specific event, such as a button click on the child component's page (when the variable totalRe ...

Exploring the differences between JavaScript destructuring and assignment

In my code, I initially used this line: const availableDays = status.availableDays; However, a suggestion was made to replace it with this line: const { availableDays } = status; Both options achieve the same result in one line of code, but I am curious ...