-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.go
43 lines (35 loc) · 971 Bytes
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package oauth
import (
"net/http"
)
type AccessTokenResponse struct {
AccessToken string `json:"access_token"`
}
type OauthUserInfo struct {
Provider ProviderType
Name string
ExternalID string
AvatarURL string
DisplayName string
}
type OAuthConfig struct {
Provider ProviderType
ClientID string
Secret string
CallbackURL string
}
type ProviderType string
const (
ProviderTypeGithub ProviderType = "GITHUB"
ProviderTypeDiscord ProviderType = "DISCORD"
ProviderTypeMesehub ProviderType = "MESEHUB"
ProviderTypeCDB ProviderType = "CDB"
ProviderTypeCodeberg ProviderType = "CODEBERG"
)
type OauthProvider interface {
// client login url
LoginURL(cfg *OAuthConfig) string
RequestAccessToken(code string, cfg *OAuthConfig) (string, error)
RequestUserInfo(access_token string, cfg *OAuthConfig) (*OauthUserInfo, error)
}
type OauthCallback func(w http.ResponseWriter, r *http.Request, user_info *OauthUserInfo) error