Server-side actions and routes for authenticating to and accessing an REST API from a web client
composer require groton-school/oauth2-api-proxyDue to CORS restrictions, a web app can't directly access an arbitrary REST API. This package provides a server-side proxy for the web client to use to access the REST API, storing the the user's API access tokens on the client side as web cookies.
- Implement
ProviderInterface. This is intended to be done with one of theLeague/oauth2-clientimplementations. See groton-school/slim-canvas-api-proxy for a concrete example (which makes use of theDefaultstraits provided for convenience). - Inject the implementation as a dependency. (Of course, make sure that you store your API credentials somewhere secure!)
- use
RouteBuilderto define the necessary routes. - Access the client from a web app. A concrete example of this is @groton/canvas-api.client.web.
groton-school/slim-skeleton's gae/lti-tool_canvas-api-proxy is the canonical example of how this shim is meant to be used.