nftstorage / nft.storage

**Notice: Uploads Decommissioned - Existing Data is Safe!** NFT.Storage Classic (classic.nft.storage) offers free decentralized storage and bandwidth for NFTs on IPFS and Filecoin. June 2024 Update: No new uploads, but all existing data is safe. Try the new NFT.Storage, which preserves data in long term Filecoin storage. Go to app.nft.storage
https://classic.nft.storage
Other
619 stars 167 forks source link

Issue with API Key: "ERROR_MALFORMED_TOKEN" #2760

Closed dsfnaw22jlg closed 1 day ago

dsfnaw22jlg commented 2 days ago

Subject: Issue with API Key: "ERROR_MALFORMED_TOKEN"

Hello,

I am experiencing an issue with the NFT.Storage service. When I try to upload images via the API, I receive the following error:

css

Error uploading C:\secretteset1\NFT_Series1_Ticket1.png: { ok: false, error: { code: 'ERROR_MALFORMED_TOKEN', message: 'API Key is malformed or failed to parse.' } } I am using the following API key: db9292f1.8e23b74622e9474b84d8050368968ac4. The key was generated via your interface, and based on the documentation, it has been entered correctly in the request.

For sending the request, I’m using the axios library in Node.js. Below is the code snippet for the request:

javascript Копировать код const axios = require('axios'); const fs = require('fs'); const FormData = require('form-data'); const path = require('path');

const uploadImageToNFTStorage = async (filePath) => { const apiKey = '***'; const url = 'https://api.nft.storage/upload';

const formData = new FormData();
formData.append('file', fs.createReadStream(filePath));

try {
    const response = await axios.post(url, formData, {
        headers: {
            'Authorization': `Bearer ${apiKey}`,
            ...formData.getHeaders(),
        },
    });

    console.log(`Uploaded ${filePath}, CID: ${response.data.value.cid}`);
} catch (error) {
    console.error(`Error uploading ${filePath}:`, error.response ? error.response.data : error.message);
}

}; I have verified the format of the key and how it is being passed in the headers, but the error persists. I also tried generating a new API key, but the problem remains.

Could you please assist in identifying the cause of this error? It seems there might be an issue with the key or how it is being processed by the system.

Thank you in advance for your help!

elizabeth-griffiths commented 1 day ago

Thank you for reaching out, and I'm sorry to hear you're encountering an issue with your API key.

The error message "API Key is malformed or failed to parse" typically occurs when an API key from https://app.nft.storage/login is used for our NFT.Storage Classic product, which includes the NFTUp feature (accessible via https://classic.nft.storage/).

Please note that API keys from https://app.nft.storage/login are only compatible with our new version of the product available at that same URL. They do not work with NFT.Storage Classic.

About the NFT.Storage Classic Transition: NFT.Storage Classic, our original service, will continue to support existing uploads but does not allow new uploads after June 30, 2024. To meet our community's evolving needs, we've launched a new flagship product at https://app.nft.storage/. This platform is where you can back up off-chain NFT data.

Steps to Resolve the Issue:

  1. Upload your data to IPFS. We suggest using Pinata or Lighthouse for this process. For a seamless experience, feel free to check out our referral links and special offers:
  1. Mint your NFTs and collect the associated data (metadata CIDs, imagery CIDs, contract address, token IDs).
  2. IPFS isn't permanent so back up your off-chain data with NFT.Storage here: https://app.nft.storage/login

If you continue to experience issues or have further questions, feel free to reach out. We're here to help!

Best regards, Elizabeth