git clone https://github.com/qqwozz/OAuth_2.0.git
cd OAuth_2.0
cp .env.example .env
# Заполните .env своими данными Auth0
go run main.goОткройте http://localhost:8080 → нажмите Sign In with Google
- Зарегистрируйтесь на auth0.com
- Создайте Regular Web Application
- Скопируйте из настроек приложения:
| Параметр | Где найти |
|---|---|
AUTH0_DOMAIN |
Applications → Your App → Domain |
AUTH0_CLIENT_ID |
Applications → Your App → Client ID |
AUTH0_CLIENT_SECRET |
Applications → Your App → Client Secret |
-
Добавьте в Allowed Callback URLs:
http://localhost:8080/callback -
Добавьте в Allowed Logout URLs:
http://localhost:8080/
| Variable | Required | Description |
|---|---|---|
AUTH0_DOMAIN |
Yes | Auth0 domain |
AUTH0_CLIENT_ID |
Yes | Auth0 client ID |
AUTH0_CLIENT_SECRET |
Yes | Auth0 client secret |
AUTH0_REDIRECT_URL |
Yes | http://localhost:8080/callback |
PORT |
No | 8080 |
| Method | Path | Auth | Description |
|---|---|---|---|
GET |
/ |
- | Home |
GET |
/login |
- | Redirect to Auth0 |
GET |
/callback |
- | OAuth callback |
GET |
/profile |
Yes | User profile |
GET |
/avatar |
Yes | Avatar proxy |
GET |
/logout |
- | Logout |
