From 0c9d05be8eeaa524f36b782c4bf25b96fff23bbd Mon Sep 17 00:00:00 2001 From: vova Date: Fri, 29 Jan 2021 22:37:47 +0200 Subject: [PATCH] feat(provider): Add medium --- src/providers/index.js | 2 ++ src/providers/medium.js | 22 ++++++++++++++++++++++ www/docs/providers/medium.md | 30 ++++++++++++++++++++++++++++++ www/providers.json | 1 + 4 files changed, 55 insertions(+) create mode 100644 src/providers/medium.js create mode 100644 www/docs/providers/medium.md diff --git a/src/providers/index.js b/src/providers/index.js index 29fbee5d17..d918923cc8 100644 --- a/src/providers/index.js +++ b/src/providers/index.js @@ -20,6 +20,7 @@ import IdentityServer4 from './identity-server4' import LINE from './line' import LinkedIn from './linkedin' import MailRu from './mailru' +import Medium from './medium' import Netlify from './netlify' import Okta from './okta' import Reddit from './reddit' @@ -55,6 +56,7 @@ export default { LINE, LinkedIn, MailRu, + Medium, Netlify, Okta, Reddit, diff --git a/src/providers/medium.js b/src/providers/medium.js new file mode 100644 index 0000000000..70e224df2f --- /dev/null +++ b/src/providers/medium.js @@ -0,0 +1,22 @@ +export default (options) => { + return { + id: 'medium', + name: 'Medium', + type: 'oauth', + version: '2.0', + scope: 'basicProfile', + params: { grant_type: 'authorization_code' }, + accessTokenUrl: 'https://api.medium.com/v1/tokens', + authorizationUrl: 'https://medium.com/m/oauth/authorize?response_type=code', + profileUrl: 'https://api.medium.com/v1/me', + profile: (profile) => { + return { + id: profile.data.id, + name: profile.data.name, + email: null, + image: profile.data.imageUrl + } + }, + ...options + } +} diff --git a/www/docs/providers/medium.md b/www/docs/providers/medium.md new file mode 100644 index 0000000000..df1b0ab7ab --- /dev/null +++ b/www/docs/providers/medium.md @@ -0,0 +1,30 @@ +--- +id: medium +title: Medium +--- + +## Documentation + +https://github.com/Medium/medium-api-docs + +## Configuration + +https://medium.com/me/applications + +## Example + +```js +import Providers from `next-auth/providers` +... +providers: [ + Providers.Medium({ + clientId: process.env.MEDIUM_CLIENT_ID, + clientSecret: process.env.MEDIUM_CLIENT_SECRET + }) +} +... +``` + +:::warning +Email address is not returned by the Medium API. +::: diff --git a/www/providers.json b/www/providers.json index 93115a8e01..b84f14f636 100644 --- a/www/providers.json +++ b/www/providers.json @@ -21,6 +21,7 @@ "line": "LINE", "linkedin": "LinkedIn", "mailru": "Mail.ru", + "medium": "Medium", "netlify": "Netlify", "okta": "Okta", "reddit": "Reddit",