0.1.7 • Published 10 months ago
@appwise/oauth2-server v0.1.7
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.7
10 months ago
0.1.6
1 year ago
0.1.5
2 years ago
0.1.2
2 years ago
0.1.1
2 years ago
0.1.4
2 years ago
0.1.3
2 years ago
0.0.20
2 years ago
0.1.0
2 years ago
0.0.17
2 years ago
0.0.18
2 years ago
0.0.19
2 years ago
0.0.15
2 years ago
0.0.16
2 years ago
0.0.13
2 years ago
0.0.14
2 years ago
0.0.10
2 years ago
0.0.11
2 years ago
0.0.12
2 years ago
0.0.9
2 years ago
0.0.8
2 years ago
0.0.7
2 years ago
0.0.6
3 years ago
0.0.5
3 years ago
0.0.4
3 years ago
0.0.3
3 years ago
0.0.2
3 years ago
0.0.1
3 years ago