Module notifier_fcm_oauth

Caches a Google OAuth 2.0 access token for the FCM HTTP v1 API.

Behaviours: gen_server.

Description

Caches a Google OAuth 2.0 access token for the FCM HTTP v1 API.

Signs an RS256 JWT with the service account's private key, exchanges it at https://oauth2.googleapis.com/token, and serves the cached access token until it is within 60 s of expiry (lazy refresh: an idle service makes no network calls). invalidate/0 drops the cache, used when FCM answers 401.

Boots without credentials (degraded): get_token/0 then returns {error, not_configured} and FCM deliveries are reported as not_configured instead of crashing the node.

Function Index

configured/0True when a service account was loaded.
get_token/0A valid access token, minting one when needed.
handle_call/3
handle_cast/2
handle_info/2
init/1
invalidate/0Forget the cached access token so the next call mints a new one.
project_id/0The Firebase project id (from the service account, or FCM_PROJECT_ID).
start_link/0

Function Details

configured/0

configured() -> boolean()

True when a service account was loaded.

get_token/0

get_token() -> {ok, binary()} | {error, term()}

A valid access token, minting one when needed.

handle_call/3

handle_call(Req, From, S) -> any()

handle_cast/2

handle_cast(Msg, S) -> any()

handle_info/2

handle_info(Info, S) -> any()

init/1

init(X1) -> any()

invalidate/0

invalidate() -> ok

Forget the cached access token so the next call mints a new one.

project_id/0

project_id() -> binary() | undefined

The Firebase project id (from the service account, or FCM_PROJECT_ID).

start_link/0

start_link() -> gen_server:start_ret()


Generated by EDoc