HTTP OAuth2
Parámetros para conexiones HTTP usando OAuth 2.0 con Client Credentials.
Esta clase extiende Base HTTP Connection con credenciales OAuth2 para el flujo de Client Credentials Grant. Ideal para aplicaciones que necesitan acceder a APIs en nombre propio, no de usuarios.
Información General:
| Tipo ID | Módulo | Categoría |
|---|---|---|
5 |
httplib |
api |
OAuth2ConnectionParams
Parámetros:
client_id: str Identificador del cliente OAuth2 proporcionado por el proveedor. Identifica la aplicación registrada.client_secret: str Secreto del cliente correspondiente a client_id. Debe mantenerse altamente confidencial.token_url: HttpUrl URL del endpoint de token del proveedor OAuth2 donde se solicita el access token.
Parámetros de entrada:
| Campo | Tipo | Requerido | Descripción | Valor por defecto | Ejemplos |
|---|---|---|---|---|---|
url |
HttpUrl | ✅ | URL completa del endpoint del servicio | PydanticUndefined |
https://api.example.com/endpoint |
headers |
Optional[dict[str, str]] | ❌ | Headers HTTP adicionales a incluir en la solicitud | None |
{"Authorization": "Bearer token", "Content-Type": "application/json"} |
method |
Literal[GET, POST, PUT, DELETE, PATCH] | ❌ | Método HTTP a utilizar | GET |
POST |
body |
Optional[dict[str, Any]] | ❌ | Cuerpo JSON de la solicitud | None |
{"key": "value"} |
verify_ssl |
bool | ❌ | Si se debe validar el certificado SSL | True |
True |
client_id |
str | ✅ | Identificador del cliente OAuth2 | PydanticUndefined |
client_id_value |
client_secret |
str | ✅ | Secreto del cliente OAuth2 | PydanticUndefined |
client_secret_value |
token_url |
HttpUrl | ✅ | URL del endpoint de token OAuth2 | PydanticUndefined |
https://auth.example.com/token |
Ejemplo:
{
"url": "https://api.example.com/oauth2",
"client_id": "client_id_value",
"client_secret": "client_secret_value",
"token_url": "https://auth.example.com/token",
"headers": {},
"method": "GET",
"body": null,
"verify_ssl": true
}
Notas:
Este modelo soporta el flujo Client Credentials de OAuth2. El código que use estos parámetros debe implementar la solicitud del token al token_url y su uso en requests subsiguientes. Los tokens tienen expiración típica, así que implementa refresh automático.