Skip to content

Commit 35ce332

Browse files
author
Ben Goshow
authored
feat(providers): add Freshbooks (#2322)
Contains the following squashed commits: * Create freshbooks.js * Create freshbooks.md * Update providers.d.ts * Update freshbooks.md * Update src/providers/freshbooks.js * Update providers.test.ts * Update freshbooks.md
1 parent ec29528 commit 35ce332

File tree

4 files changed

+60
-0
lines changed

4 files changed

+60
-0
lines changed

src/providers/freshbooks.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
export default function Freshbooks(options) {
2+
return {
3+
id: 'freshbooks',
4+
name: 'Freshbooks',
5+
type: 'oauth',
6+
version: '2.0',
7+
params: { grant_type: 'authorization_code' },
8+
accessTokenUrl: 'https://api.freshbooks.com/auth/oauth/token',
9+
authorizationUrl: 'https://auth.freshbooks.com/service/auth/oauth/authorize?response_type=code',
10+
profileUrl: 'https://api.freshbooks.com/auth/api/v1/users/me',
11+
async profile(profile) {
12+
return {
13+
id: profile.response.id,
14+
name: `${profile.response.first_name} ${profile.response.last_name}`,
15+
email: profile.response.email,
16+
};
17+
},
18+
...options
19+
};
20+
}

types/providers.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ export type OAuthProviderType =
7272
| "FACEIT"
7373
| "FortyTwo"
7474
| "Foursquare"
75+
| "Freshbooks"
7576
| "FusionAuth"
7677
| "GitHub"
7778
| "GitLab"

types/tests/providers.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,3 +257,9 @@ Providers.Zoho({
257257
clientId: "foo123",
258258
clientSecret: "bar123",
259259
})
260+
261+
// $ExpectType OAuthConfig<Profile>
262+
Providers.Freshbooks({
263+
clientId: "foo123",
264+
clientSecret: "bar123",
265+
})

www/docs/providers/freshbooks.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
id: freshbooks
3+
title: Freshbooks
4+
---
5+
6+
## Documentation
7+
8+
https://www.freshbooks.com/api/authenticating-with-oauth-2-0-on-the-new-freshbooks-api
9+
10+
## Configuration
11+
12+
https://my.freshbooks.com/#/developer
13+
14+
## Options
15+
16+
The Freshbooks Provider comes with a set of default options:
17+
18+
https://www.freshbooks.com/api/start
19+
20+
You can override any of the options to suit your own use case.
21+
## Example
22+
23+
```js
24+
import Providers from `next-auth/providers`
25+
...
26+
providers: [
27+
Providers.Freshbooks({
28+
clientId: process.env.FRESHBOOKS_CLIENT_ID,
29+
clientSecret: process.env.FRESHBOOKS_CLIENT_SECRET,
30+
})
31+
]
32+
...
33+
```

0 commit comments

Comments
 (0)