0.1.6 • Published 3 months ago
@appwise/oauth2-server v0.1.6
express-oauth2
Installation
npm install express-oauth2
Adding a authentication method to your project
In order to add a new authentication method to your project, first add the new integration:
export const oauth: OAuth2Server = createOAuth2({
scopes: Object.values(Scope),
services: {
userService,
clientService,
tokenService
},
integrations: {
google: true
}
})
Add the integration to the client grants in the client service:
client.grants = ['password', 'refresh_token', 'google']
Implement the integration user service method:
createOrGetGoogleUser?: (payload: IGoogleResponse) => Promise<User>
async createOrGetGoogleUser (payload: IGoogleResponse): Promise<User> {
const user = await User.findOne({ where: { email: payload.email } })
if (user != null) return user
const newUser = User.create({
email: payload.email,
password: this.getRandomPassword()
})
await this.hashPassword(newUser, newUser.password)
return await newUser.save()
}
0.1.6
3 months ago
0.1.5
6 months ago
0.1.2
6 months ago
0.1.1
6 months ago
0.1.4
6 months ago
0.1.3
6 months ago
0.0.20
9 months ago
0.1.0
8 months ago
0.0.17
9 months ago
0.0.18
9 months ago
0.0.19
9 months ago
0.0.15
12 months ago
0.0.16
11 months ago
0.0.13
1 year ago
0.0.14
12 months ago
0.0.10
1 year ago
0.0.11
1 year ago
0.0.12
1 year ago
0.0.9
1 year ago
0.0.8
1 year ago
0.0.7
1 year ago
0.0.6
1 year ago
0.0.5
2 years ago
0.0.4
2 years ago
0.0.3
2 years ago
0.0.2
2 years ago
0.0.1
2 years ago