You are reading the Saleor App Framework (Python) documentation. This document should help you to quickly bootstrap a 3rd Party Saleor App, read more about those Saleor's documentation.
fromsaleor_app.appimportSaleorAppapp=SaleorApp(# more arguments to come)
You can use the app instance as you would normally use the standard one, i.e. to initialize Sentry or add Middleware. None of the core FastAPI logic is changed by the framework.
As described in App manifest an app needs a manifest, the framework provides a Pydantic representation of that which needs to be provided when initializing the app.
fromsaleor_app.appimportSaleorAppfromsaleor_app.schemas.manifestimportManifestfromsaleor_app.schemas.utilsimportLazyUrlmanifest=Manifest(name="Sample Saleor App",version="0.1.0",about="Sample Saleor App seving as an example.",data_privacy="",data_privacy_url="http://samle-saleor-app.example.com/dataPrivacyUrl",homepage_url="http://samle-saleor-app.example.com/homepageUrl",support_url="http://samle-saleor-app.example.com/supportUrl",id="saleor-simple-sample",permissions=["MANAGE_PRODUCTS","MANAGE_USERS"],configuration_url=LazyUrl("configuration-form"),extensions=[],)app=SaleorApp(manifest=manifest,# more arguments to come)
LazyUrl
saleor_app.schemas.utils.LazyUrl is a lazy loader for app url paths, when a manifest is requested the app will resolve the path name to a full url of that endpoint.
3rd Patry Apps work in a multi-tenant fashion - one app service can serve multiple Saleor instances. To prevent any Saleor instance from using your app the app need to authorize a Saleor instance that's done by a simple function that can be as simple as comparing the incoming Saleor domain or as complex to check the allowed domains in a database.
fromsaleor_app.appimportSaleorAppfromsaleor_app.schemas.coreimportDomainNamefromsaleor_app.schemas.manifestimportManifestfromsaleor_app.schemas.utilsimportLazyUrlasyncdefvalidate_domain(saleor_domain:DomainName)->bool:returnsaleor_domain=="172.17.0.1:8000"manifest=Manifest(name="Sample Saleor App",version="0.1.0",about="Sample Saleor App seving as an example.",data_privacy="",data_privacy_url="http://samle-saleor-app.example.com/dataPrivacyUrl",homepage_url="http://samle-saleor-app.example.com/homepageUrl",support_url="http://samle-saleor-app.example.com/supportUrl",id="saleor-simple-sample",permissions=["MANAGE_PRODUCTS","MANAGE_USERS"],configuration_url=LazyUrl("configuration-form"),extensions=[],)app=SaleorApp(manifest=manifest,validate_domain=validate_domain,# more arguments to come)
When Saleor is authorized to install the app an authentication key is issued, that key needs to be securely stored by the app as it provides as much access as the app requested in the manifest.