npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@silvacreate/ally-pinterest-driver

v0.0.18

Published

AdonisJS Ally driver for Pinterest

Readme

ally-pinterest-driver

An AdonisJS Ally driver for Pinterest OAuth2 authentication.

This package provides a custom driver for AdonisJS Ally to authenticate users via Pinterest. It allows you to easily request access to a user's Pinterest account, fetch their profile, and manage access/refresh tokens.

Installation

Install the package using your preferred package manager:

npm install @silvacreate/ally-pinterest-driver
# or
yarn add @silvacreate/ally-pinterest-driver
# or
pnpm add @silvacreate/ally-pinterest-driver

Configuration

1. Environment Variables

First, add your Pinterest OAuth credentials to your .env file. You can obtain these by creating an app in the Pinterest Developer Portal.

PINTEREST_CLIENT_ID=your_client_id
PINTEREST_CLIENT_SECRET=your_client_secret
PINTEREST_CALLBACK_URL=http://localhost:3333/pinterest/callback

Make sure to validate these inside your start/env.ts file:

// start/env.ts
export default Env.create(new URL('../', import.meta.url), {
  PINTEREST_CLIENT_ID: Env.schema.string(),
  PINTEREST_CLIENT_SECRET: Env.schema.string(),
  PINTEREST_CALLBACK_URL: Env.schema.string(),
})

2. Configure Ally

Open your config/ally.ts file and register the Pinterest driver:

import env from '#start/env'
import { defineConfig } from '@adonisjs/ally'
import { PinterestDriverService } from '@silvacreate/ally-pinterest-driverr'

const allyConfig = defineConfig({
  pinterest: PinterestDriverService({
    clientId: env.get('PINTEREST_CLIENT_ID'),
    clientSecret: env.get('PINTEREST_CLIENT_SECRET'),
    callbackUrl: env.get('PINTEREST_CALLBACK_URL'),
  }),
})

export default allyConfig

declare module '@adonisjs/ally/types' {
  interface SocialProviders extends InferSocialProviders<typeof allyConfig> {}
}

Usage

You will need two routes and corresponding controller methods: one to redirect the user to Pinterest, and one to handle the callback.

1. Redirecting to Pinterest

Use the redirect method to send the user to Pinterest's authorization page. You can define the specific scopes your application needs here.

import type { HttpContext } from '@adonisjs/core/http'

export default class PinterestAuthController {
  async redirect({ ally }: HttpContext) {
    
    return ally.use('pinterest').redirect((request) => {
      request.scopes([
        'boards:write',
        'boards:read',
        'pins:write',
        'pins:read',
        'user_accounts:read',
      ])
    })
  }
}

2. Handling the Callback

Once the user authorizes your app, Pinterest will redirect them back to your callback URL. You can then verify the request and fetch the user's profile and tokens.

import type { HttpContext } from '@adonisjs/core/http'

export default class PinterestAuthController {
  async callback({ ally, response }: HttpContext) {
    const pinterest = ally.use('pinterest')

    // 1. Handle user denying access
    if (pinterest.accessDenied()) {
      return 'Access denied. You cancelled the login process.'
    }

    // 2. Prevent CSRF attacks
    if (pinterest.stateMisMatch()) {
      return 'State mismatch. Request may have been tampered with.'
    }

    // 3. Handle unknown errors
    if (pinterest.hasError()) {
      return pinterest.getError()
    }

    try {
      const pinterestUser = await pinterest.user()
      // 4 Your logic
    
    } catch (error) {
      return response.badRequest('OAuth failed. Check server logs.')
    }
  }
}