onasty/internal/oauth/oauth.go (view raw)
Smirnov Oleksandr
Smirnov Oleksandr
ss2316544@gmail.com feat: add oauth2 login for google and github (#109)..., 1 year ago
ss2316544@gmail.com feat: add oauth2 login for google and github (#109)..., 1 year ago
| 1 | package oauth |
| 2 | |
| 3 | import "context" |
| 4 | |
| 5 | // Provider is an OAuth interface. |
| 6 | type Provider interface { |
| 7 | // GetAuthURL return the provider's authorization page URL. |
| 8 | GetAuthURL(state string) string |
| 9 | |
| 10 | // ExchangeCode exchanges the provided authorization code for user information. |
| 11 | ExchangeCode(ctx context.Context, code string) (UserInfo, error) |
| 12 | } |
| 13 | |
| 14 | // UserInfo represents the user information returned by the OAuth provider. |
| 15 | type UserInfo struct { |
| 16 | // Provider is the name of the OAuth provider |
| 17 | Provider string |
| 18 | // ProviderID is user ID assigned by the provider |
| 19 | ProviderID string |
| 20 | // Email is user's email address returned by the provider |
| 21 | Email string |
| 22 | // EmailVerified indicates whether the email was verified by the provider |
| 23 | EmailVerified bool |
| 24 | } |