banshee is under active development: collectors will keep changing, and a version you publish will likely need adjustments. For stable use, wait for version 1.0.0.

Examples

banshee/examples-collection/examples/api/

oauth-token

Example: an OAuth2 token, url.query, Basic and base64.url_decode; the lifetime of the tokens.

  • example
  • api
  • oauth2
  • jwt
  • http
  • encoding

by banshee1 installation1 version

v1Latest

Published on October 27, 2026. First version in this collection.

An OAuth2 token

The client credentials grant of OAuth2: the client id and its secret in Basic, the form body written by url.query. The collector watches how long the tokens the server hands out live, read in the token itself.

How to read it

  • url.query(array('grant_type' => …, 'scope' => …)) writes grant_type=client_credentials&scope=monitoring%20read: each key and value encoded, the pairs sorted by key and joined by &. Never build a form body or a query by concatenation alone: a &, a = or a blank in a value would break it.
  • The type of the body is the header Content-Type: application/x-www-form-urlencoded, written by the author.
  • A JWT is three parts joined by points; text.split cuts them. The middle one is JSON in base64 for addresses: base64.url_decode, then json.read.
  • exp and iat are seconds since 1970: their difference is the lifetime of the token.

To adapt it

  • A server that sends the client secret in the body instead of Basic: put client_id and client_secret in url.query. The body then carries a secret, the whole answer becomes a secret, and its lifetime can no longer be returned as a value.