Use a standard OAuth 2.0 or OpenID Connect client library for your front-end framework rather than the raw protocol. Lobyco recommends it because the library handles PKCE, the redirects, token storage and silent renewal for you.
Before you start
Ask Lobyco to register the website as a public OAuth client in Lobyco IDP. Lobyco needs:- The client name, that is your application’s name.
- The redirect URIs: the exact URLs customers return to after signing in, such as
https://example.com/callback.
IDENTITY_BASE_URL and CLIENT_ID.
The flow
1
2
Exchange the code for tokens
access_token, for calling the Lobyco APIs.id_token, the customer’s identity, when OpenID Connect is enabled for the client.refresh_token, for renewing the tokens, when the client is allowed one.
3
Call the APIs with the access token
Put the access token in theAuthorization header of each request:Scopes
Validate tokens on your backend
Which check your backend runs depends on the token type. A JWT access token is validated locally against the issuer’sjwks_uri. An opaque access token is checked by calling the introspection endpoint, /oauth2/introspect.
Failure and edge cases
The usual failure is a redirect URI mismatch. Theredirect_uri must match exactly what Lobyco registered, including the scheme and the path. Otherwise Lobyco IDP refuses the request before the customer sees a sign-in page.
Related
- Mobile app authentication — the same identity provider in the app, and the external-provider mode.