com.deucarian.session.api-integration
v1.0.1-dev.2
Published
Integration package that exposes Deucarian Session tokens through Deucarian API authentication.
Maintainers
Readme
Deucarian Session API Integration
Overview
Deucarian Session API Integration is a Unity UPM package that connects Session to API authentication.
Package ID: com.deucarian.session.api-integration
Migration note: replace old manifest entries for com.deucarian.session.api-bridge with com.deucarian.session.api-integration. The source repository URL still uses Session-API-Bridge.git until the GitHub repository is renamed.
Use this package when a Unity project already uses both:
com.deucarian.sessioncom.deucarian.api
The integration provides SessionAuthProvider, an API IApiAuthProvider implementation backed by an ISessionService.
No scripting define symbols are required.
Installation
Install this integration package alongside Session and API:
{
"dependencies": {
"com.deucarian.session": "https://github.com/Deucarian/Session.git#main",
"com.deucarian.api": "https://github.com/Deucarian/API.git#main",
"com.deucarian.session.api-integration": "https://github.com/Deucarian/Session-API-Bridge.git#main"
}
}For development builds, use the develop branch refs for each package.
Dependencies
This package depends on:
com.deucarian.sessioncom.deucarian.api
It does not replace either package. It only adapts Session's current session token to API's authentication contract.
Public API
SessionAuthProvider: implements API'sIApiAuthProviderand reads tokens from anISessionService.
Usage
using Deucarian.API.Core;
using Deucarian.Session;
using Deucarian.Session.APIIntegration;
ISessionService sessionService = new SessionService(
new PlayerPrefsSessionStore("my-game.session"),
new MyRefreshService());
var authProvider = new SessionAuthProvider(sessionService);
IApiClient apiClient = ApiClientFactory.Create(apiClientConfig, authProvider);SessionAuthProvider returns the access token without the Bearer prefix. API owns the authorization header formatting.
Refresh Behavior
By default, SessionAuthProvider attempts ISessionService.RefreshAsync when the current access token is expired or expiring soon.
var authProvider = new SessionAuthProvider(
sessionService,
refreshIfExpiredOrExpiringSoon: true);Disable refresh attempts by passing false:
var authProvider = new SessionAuthProvider(
sessionService,
refreshIfExpiredOrExpiringSoon: false);If refresh fails, the provider does not throw or clear the session itself. It returns based on the ISessionService state after the refresh attempt:
- Expired sessions return
null. - Still-valid expiring-soon sessions may return the current token when
SessionRefreshFailurePolicy.PreserveSessionkeeps the session authenticated.
Samples
The package contains one sample:
Basic API Integration Usage- Path:
Samples~/BasicUsage - Script:
SessionAuthProviderSample
The sample uses fake session data and a fake refresh service. It does not make backend calls.
What This Package Does Not Own
- Session storage.
- Login and refresh backend calls.
- API request execution.
- Authorization header formatting.
- API package behavior.
- Session core runtime APIs.
