Skip to content

Instantly share code, notes, and snippets.

@gustavocoleta
Created July 19, 2024 11:36
Show Gist options
  • Save gustavocoleta/5b2814af55bdfdd79d82d6bf94b3cfe7 to your computer and use it in GitHub Desktop.
Save gustavocoleta/5b2814af55bdfdd79d82d6bf94b3cfe7 to your computer and use it in GitHub Desktop.

Esquema básico de Autenticação OAuth2 usando o Kong Gateway

Documentação completa: aqui

1. Request inicial solicitando o código de autorização:

curl -X POST \
--header 'Content-Type: application/json' \
--data '{
"client_id": "GUO6Qo7r6i0JaP9zLgk0GOeb1KIzelCn", 
"authenticated_userid": "pdv", 
"response_type": "code", 
"scope": "pdv", 
"provision_key": "E73oMWOyXxNhf7oRfsHkuAc5B4gobPIE", 
"redirect_url": "https://staging-master.vrsoft.com.br/oauth_return"
}' https://staging-master.vrsoft.com.br/api/v1/pessoa/rotativo/consultar/oauth2/authorize

2. Com o código gerado, solicitar o token de autenticação e o token de refresh:

curl -X POST \
--header 'Content-Type: application/json' \
--data '{
"grant_type": "authorization_code", 
"code": "[COLOCAR O CÓDIGO GERADO AQUI!]", 
"client_id": "GUO6Qo7r6i0JaP9zLgk0GOeb1KIzelCn", 
"client_secret": "n7j5HtJzCA35exqi2YkF7uskC2EG4TMq"
}' https://staging-master.vrsoft.com.br/api/v1/pessoa/rotativo/consultar/oauth2/token

3. Realizar a request passando o token de autorização:

curl \
--header 'authorization: [TOKEN DE ACESSO GERADO AQUI!]' \
https://staging-master.vrsoft.com.br/api/v1/pessoa/rotativo/consultar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment