IPFS Pins and Stats

I have code that seems to work. But my Infura stats don’t show any traffic, and the Explorer says I have no Pins.

Here is my code:

const auth = 'Basic ' + projectId + ':' + projectSecret.toString('base64');
const client = await IpfsHttpClient.create({
  host: 'ipfs.infura.io',
  port: 5001,
  protocol: 'https',
  apiPath: '/api/v0',
  headers: {
     authorization: auth

const version = await client.version();
console.log("IPFS Node Version:", version.version);

  for (var i = 0; i < input.files.length; ++i) {

    try {
      const file = await client.add(input.files[i])

      await client.pin.add(file.cid).then((res) => {
        console.log('Results of Pin: ' + res)

      console.log('https://ipfs.io/ipfs/' + file.path)
    } catch (error) {

Can anyone help? Seems like I wouldn’t be the only one having this issue.

hey, are you still seeing this problem ?

Yes! It is still an issue.

hey @atomniketh apologies, I seem to have missed your reply. The issue here is that your client didn’t look to use the auth properly. That combined with the fact that one could pin (for now) without auth made this issue hard to spot. :slight_smile:
You’ll have to encode the projectId as well:

const auth = 'Basic ’ + Buffer.from(projectId + ‘:’ + projectSecret).toString(‘base64’);


1 Like

Thanks Traian!

Can you suggest another way to encode the Project ID and Secret string? I’m not using react or angular, etc. Trying to do it super lightweight in JS.

Just tried, without success:
var enc = new TextEncoder();
const auth = 'Basic ’ + enc.encode(projectId + ‘:’ + projectSecret).toString(‘base64’);


I figured it out! This is how I got it to work:

    const auth = 'Basic ' + window.btoa(projectId + ':' + projectSecret).toString('base64');
1 Like

Nice, thanks for posting this ! :slight_smile: