Skip to content

Commit 831c59d

Browse files
authored
feat: add foursquare (#584)
1 parent 3abb0c8 commit 831c59d

File tree

5 files changed

+57
-2
lines changed

5 files changed

+57
-2
lines changed

src/providers/foursquare.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
export default ({ apiVersion, ...options }) => {
2+
return {
3+
id: 'foursquare',
4+
name: 'Foursquare',
5+
type: 'oauth',
6+
version: '2.0',
7+
params: { grant_type: 'authorization_code' },
8+
accessTokenUrl: 'https://foursquare.com/oauth2/access_token',
9+
authorizationUrl:
10+
'https://foursquare.com/oauth2/authenticate?response_type=code',
11+
profileUrl: `https://api.foursquare.com/v2/users/self?v=${apiVersion}`,
12+
profile: (profile) => {
13+
return {
14+
id: profile.id,
15+
name: `${profile.firstName} ${profile.lastName}`,
16+
image: `${profile.prefix}original${profile.suffix}`,
17+
email: profile.contact.email
18+
}
19+
},
20+
...options
21+
}
22+
}

src/providers/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import Cognito from './cognito'
1010
import Discord from './discord'
1111
import Email from './email'
1212
import Facebook from './facebook'
13+
import Foursquare from './foursquare'
1314
import FusionAuth from './fusionauth'
1415
import GitHub from './github'
1516
import GitLab from './gitlab'
@@ -38,6 +39,7 @@ export default {
3839
Discord,
3940
Email,
4041
Facebook,
42+
Foursquare,
4143
FusionAuth,
4244
GitHub,
4345
GitLab,

www/docs/configuration/providers.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ NextAuth.js is designed to work with any OAuth service, it supports OAuth 1.0, 1
2020
* [Amazon Cognito](/providers/cognito)
2121
* [Discord](/providers/discord)
2222
* [Facebook](/providers/facebook)
23+
* [Foursquare](/providers/foursquare)
2324
* [FusionAuth](/providers/fusionauth)
2425
* [GitHub](/providers/github)
2526
* [GitLab](/providers/gitlab)
@@ -104,7 +105,7 @@ As an example of what this looks like, this is the the provider object returned
104105
clientSecret: ''
105106
}
106107
```
107-
You can replace all the options in this JSON object with the ones from your custom provider – be sure to give it a unique ID and specify the correct OAuth version - and add it to the providers option:
108+
You can replace all the options in this JSON object with the ones from your custom provider – be sure to give it a unique ID and specify the correct OAuth version - and add it to the providers option:
108109

109110
```js title="pages/api/auth/[...nextauth].js"
110111
...

www/docs/faq.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ You can use also NextAuth.js with any database using a custom database adapter,
2323

2424
### What authentication services does NextAuth.js support?
2525

26-
NextAuth.js includes built-in support for signing in with Apple, Atlassian, Auth0, Google, Battle.net, Box, AWS Cognito, Discord, Facebook, FusionAuth, GitHub, GitLab, Google, Open ID Identity Server, Mixer, Netlify, Okta, Slack, Spotify, Twitch, Twitter and Yandex.
26+
NextAuth.js includes built-in support for signing in with Apple, Atlassian, Auth0, Google, Battle.net, Box, AWS Cognito, Discord, Facebook, Foursquare, FusionAuth, GitHub, GitLab, Google, Open ID Identity Server, Mixer, Netlify, Okta, Slack, Spotify, Twitch, Twitter and Yandex.
2727

2828
NextAuth.js also supports email for passwordless sign in, which is useful for account recovery or for people who are not able to use an account with the configured OAuth services (e.g. due to service outage, account suspension or otherwise becoming locked out of an account).
2929

www/docs/providers/foursquare.md

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
id: foursquare
3+
title: Foursquare
4+
---
5+
6+
## Documentation
7+
8+
https://developer.foursquare.com/docs/places-api/authentication/#web-applications
9+
10+
## Configuration
11+
12+
https://developer.foursquare.com/
13+
14+
:::warning
15+
Foursquare requires an additional `apiVersion` parameter in [`YYYYMMDD` format](https://developer.foursquare.com/docs/places-api/versioning/), which essentially states "I'm prepared for API changes up to this date".
16+
17+
## Example
18+
19+
```js
20+
import Providers from `next-auth/providers`
21+
...
22+
providers: [
23+
Providers.Foursquare({
24+
clientId: process.env.FOURSQUARE_CLIENT_ID,
25+
clientSecret: process.env.FOURSQUARE_CLIENT_SECRET,
26+
apiVersion: 'YYYYMMDD'
27+
})
28+
}
29+
...
30+
```

0 commit comments

Comments
 (0)