Decorator function to register an OAuth authentication provider.
The decorated function must:
This function can be imported from the squirrels.auth or the squirrels module.
Arguments
The name of the provider (must be unique, e.g., ‘google’)
The display label of the provider (e.g., ‘Google’)
The URL of the icon for the provider
Example
from squirrels import auth, arguments as args
@auth.provider(
name="google", label="Google",
icon="https://www.google.com/favicon.ico"
)
def google_auth_provider(sqrl: args.AuthProviderArgs) -> auth.ProviderConfigs:
def get_user(user_info: dict) -> auth.RegisteredUser:
# Convert OAuth user info to RegisteredUser
pass
provider_configs = auth.ProviderConfigs(
client_id=sqrl.env_vars["GOOGLE_CLIENT_ID"],
client_secret=sqrl.env_vars["GOOGLE_CLIENT_SECRET"],
server_url="https://accounts.google.com",
client_kwargs={"scope": "openid email profile"},
get_user=get_sqrl_user
)
return provider_configs