Skip to content

Commit 38a03ed

Browse files
ranjan-purbeybalazsorban44
andauthoredOct 9, 2022
feat(providers): Add Pinterest Provider (#5485)
* feat(providers): Add Pinterest Provider * Apply suggestions from code review * Update pinterest.ts * Update pinterest.ts * Apply suggestions from code review Co-authored-by: Balázs Orbán <info@balazsorban.com>
1 parent e1eb684 commit 38a03ed

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed
 

‎docs/docs/providers/pinterest.md

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
id: pinterest
3+
title: Pinterest
4+
---
5+
6+
## Documentation
7+
8+
https://developers.pinterest.com/docs/getting-started/authentication/
9+
10+
## Configuration
11+
12+
https://developers.pinterest.com/apps/
13+
14+
## Options
15+
16+
The **Pinterest Provider** comes with a set of default options:
17+
18+
- [Pinterest Provider options](https://github.com/nextauthjs/next-auth/blob/main/packages/next-auth/src/providers/pinterest.ts)
19+
20+
You can override any of the options to suit your own use case.
21+
22+
## Example
23+
24+
```ts
25+
import PinterestProvider from "next-auth/providers/pinterest"
26+
...
27+
providers: [
28+
PinterestProvider({
29+
clientId: process.env.PINTEREST_ID,
30+
clientSecret: process.env.PINTEREST_SECRET
31+
})
32+
]
33+
...
34+
35+
:::tip
36+
To use in production, make sure the app has standard API access and not trial access
37+
:::
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { OAuthConfig, OAuthUserConfig } from "."
2+
3+
export interface PinterestProfile extends Record<string, any> {
4+
account_type: "BUSINESS" | "PINNER"
5+
profile_image: string
6+
website_url: string
7+
username: string
8+
}
9+
10+
export default function PinterestProvider<P extends PinterestProfile>(
11+
options: OAuthUserConfig<P>
12+
): OAuthConfig<P> {
13+
return {
14+
id: "pinterest",
15+
name: "Pinterest",
16+
type: "oauth",
17+
authorization: {
18+
url: "https://www.pinterest.com/oauth",
19+
params: { scope: "user_accounts:read" },
20+
},
21+
checks: ["state"],
22+
token: "https://api.pinterest.com/v5/oauth/token",
23+
userinfo: "https://api.pinterest.com/v5/user_account",
24+
profile({ username, profile_image }) {
25+
return {
26+
id: username,
27+
name: username,
28+
image: profile_image,
29+
email: null,
30+
}
31+
},
32+
options,
33+
}
34+
}

1 commit comments

Comments
 (1)
Please sign in to comment.