Files
emall-api/FutureMailAPI/OAuthTest.http
2025-10-16 09:56:36 +08:00

37 lines
1.1 KiB
HTTP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// OAuth 2.0
// 1. OAuth
POST http://localhost:5001/api/v1/oauth/clients
Content-Type: application/json
{
"clientName": "TestClient",
"redirectUris": ["http://localhost:3000/callback"],
"scopes": ["read", "write"]
}
###
// 2. 访URL
// http://localhost:5001/api/v1/oauth/authorize?response_type=code&client_id=test_client&redirect_uri=http://localhost:3000/callback&scope=read&state=xyz
###
// 3. 使访
POST http://localhost:5001/api/v1/oauth/token
Content-Type: application/x-www-form-urlencoded
grant_type=authorization_code&code=YOUR_AUTHORIZATION_CODE&redirect_uri=http://localhost:3000/callback&client_id=test_client&client_secret=YOUR_CLIENT_SECRET
###
// 4. 使访访API
GET http://localhost:5001/api/v1/mails
Authorization: Bearer YOUR_ACCESS_TOKEN
###
// 5. 访
POST http://localhost:5001/api/v1/oauth/token
Content-Type: application/x-www-form-urlencoded
grant_type=refresh_token&refresh_token=YOUR_REFRESH_TOKEN&client_id=test_client&client_secret=YOUR_CLIENT_SECRET