Usina BRAdvPL Guide
Sign in
← All topics
PRACTICAL GUIDEUnder review

Authentication, headers and HTTP status in REST

Separates credentials, authorization, transport and responses in Protheus REST.

Authentication, headers and HTTP status in RESTAdvPL
01 · OVERVIEW

Overview

Identify the implementation first: REST AdvPL/2.0 and tlppCore authentication configurations are not interchangeable. The Protheus flow documents Basic and Bearer. Basic encodes credentials in Base64 without encryption; use HTTPS. In JWT flows, send access_token in Authorization: Bearer; refresh_token belongs to renewal and does not replace the access token. Read expires_in from the response instead of assuming a universal lifetime. TOTVS states authentication is mandatory from release 12.1.2410: do not reuse old advice to disable Security. Keep credentials out of URLs, versioned code and logs. (TOTVS, n.d., refs. 1–4) Interpret 401 as requiring valid authentication and 403 as refusal to fulfill the request; 404 indicates a missing resource and 500 a server error. HTTP 200 does not replace validating the business result in the body. The example represents HTTP with a fictional domain, route and token, not a real endpoint call or a configuration recipe. (IETF, 2022, ref. 5)

Return value

No single return value: this is a composite workflow.

03 · PRACTICAL EXAMPLE

Commented example

GET /rest/test-resource HTTP/1.1
Host: api.example.invalid
Accept: application/json
Authorization: Bearer <ACCESS_TOKEN>
Expected result

No request was executed. Use a contracted resource route and obtain a token through the supported flow without publishing it. Handle status and body separately. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

BEST PRACTICES
  • Store secrets using an environment-appropriate mechanism, restrict permissions and renew tokens under the contract. Exclude Authorization, passwords and refresh_token from logs; test absent and expired tokens and unauthorized users.
  • Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Related content

REFERENCES
  1. TOTVS. Entendendo as novidades do REST. TDN. Accessed on 2026-10-26.
  2. TOTVS. Fluxo básico de autenticação Rest no Protheus. Central de Atendimento. Accessed on 2026-10-26.
  3. TOTVS. Requisição para Token JWT Rest. Central de Atendimento. Accessed on 2026-10-26.
  4. TOTVS. WebService: Authentication / User not authorized. Central de Atendimento. Accessed on 2026-10-26.
  5. IETF. RFC 9110: HTTP Semantics, 2022, seção 15. Accessed on 2026-10-26.
Status
Under review
Page created on
Last reviewed on
Original language
Portuguese
Reviewed by
Usina.BR
0 approved comment(s)

Comments

There are no approved comments yet.

Sign in with Google or Microsoft to comment.

Powered by Usina Docs · Alpha