Skip to content

Commit

Permalink
feat: add foursquare (#584)
Browse files Browse the repository at this point in the history
  • Loading branch information
joe-bell authored and balazsorban44 committed Feb 1, 2021
1 parent 958c31a commit f72ee5e
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 2 deletions.
22 changes: 22 additions & 0 deletions src/providers/foursquare.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
export default ({ apiVersion, ...options }) => {
return {
id: 'foursquare',
name: 'Foursquare',
type: 'oauth',
version: '2.0',
params: { grant_type: 'authorization_code' },
accessTokenUrl: 'https://foursquare.com/oauth2/access_token',
authorizationUrl:
'https://foursquare.com/oauth2/authenticate?response_type=code',
profileUrl: `https://api.foursquare.com/v2/users/self?v=${apiVersion}`,
profile: (profile) => {
return {
id: profile.id,
name: `${profile.firstName} ${profile.lastName}`,
image: `${profile.prefix}original${profile.suffix}`,
email: profile.contact.email
}
},
...options
}
}
2 changes: 2 additions & 0 deletions src/providers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Cognito from './cognito'
import Discord from './discord'
import Email from './email'
import Facebook from './facebook'
import Foursquare from './foursquare'
import FusionAuth from './fusionauth'
import GitHub from './github'
import GitLab from './gitlab'
Expand Down Expand Up @@ -38,6 +39,7 @@ export default {
Discord,
Email,
Facebook,
Foursquare,
FusionAuth,
GitHub,
GitLab,
Expand Down
3 changes: 2 additions & 1 deletion www/docs/configuration/providers.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ NextAuth.js is designed to work with any OAuth service, it supports OAuth 1.0, 1
* [Amazon Cognito](/providers/cognito)
* [Discord](/providers/discord)
* [Facebook](/providers/facebook)
* [Foursquare](/providers/foursquare)
* [FusionAuth](/providers/fusionauth)
* [GitHub](/providers/github)
* [GitLab](/providers/gitlab)
Expand Down Expand Up @@ -104,7 +105,7 @@ As an example of what this looks like, this is the the provider object returned
clientSecret: ''
}
```
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:
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:

```js title="pages/api/auth/[...nextauth].js"
...
Expand Down
2 changes: 1 addition & 1 deletion www/docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ You can use also NextAuth.js with any database using a custom database adapter,

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

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.
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.

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).

Expand Down
30 changes: 30 additions & 0 deletions www/docs/providers/foursquare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
id: foursquare
title: Foursquare
---

## Documentation

https://developer.foursquare.com/docs/places-api/authentication/#web-applications

## Configuration

https://developer.foursquare.com/

:::warning
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".

## Example

```js
import Providers from `next-auth/providers`
...
providers: [
Providers.Foursquare({
clientId: process.env.FOURSQUARE_CLIENT_ID,
clientSecret: process.env.FOURSQUARE_CLIENT_SECRET,
apiVersion: 'YYYYMMDD'
})
}
...
```

0 comments on commit f72ee5e

Please sign in to comment.