mirror of
https://github.com/steveiliop56/tinyauth.git
synced 2026-03-22 14:37:53 +00:00
24 lines
770 B
Go
24 lines
770 B
Go
package service
|
|
|
|
import (
|
|
"github.com/steveiliop56/tinyauth/internal/config"
|
|
"golang.org/x/oauth2/endpoints"
|
|
)
|
|
|
|
func newGoogleOAuthService(config config.OAuthServiceConfig) *OAuthService {
|
|
scopes := []string{"openid", "email", "profile"}
|
|
config.Scopes = scopes
|
|
config.AuthURL = endpoints.Google.AuthURL
|
|
config.TokenURL = endpoints.Google.TokenURL
|
|
config.UserinfoURL = "https://openidconnect.googleapis.com/v1/userinfo"
|
|
return NewOAuthService(config)
|
|
}
|
|
|
|
func newGitHubOAuthService(config config.OAuthServiceConfig) *OAuthService {
|
|
scopes := []string{"read:user", "user:email"}
|
|
config.Scopes = scopes
|
|
config.AuthURL = endpoints.GitHub.AuthURL
|
|
config.TokenURL = endpoints.GitHub.TokenURL
|
|
return NewOAuthService(config).WithUserinfoExtractor(githubExtractor)
|
|
}
|