Skip to main content

Nestipy pakcage for social network authentification

Project description

Nestipy Logo

Version Python License

Description

Nestipy is a Python framework built on top of FastAPI that follows the modular architecture of NestJS

Under the hood, Nestipy makes use of FastAPI, but also provides compatibility with a wide range of other libraries, like Blacksheep, allowing for easy use of the myriad of third-party plugins which are available.

Getting started

    pip install nestipy-socialite

app_module.py

import os

from dotenv import load_dotenv
from nestipy.common import Module

from app_controller import AppController
from app_service import AppService
from nestipy_socialite import SocialiteModule, SocialiteConfig
from nestipy_socialite import GoogleOAuthProvider, FacebookOAuthProvider

load_dotenv()


@Module(
    imports=[
        SocialiteModule.register(
            SocialiteConfig(
                providers={
                    "google": GoogleOAuthProvider(
                        client_id=os.environ.get("GOOGLE_CLIENT_ID"),
                        client_secret=os.environ.get("GOOGLE_CLIENT_SECRET"),
                        redirect_uri=os.environ.get("GOOGLE_REDIRECT_URI")
                    ),
                    "facebook": FacebookOAuthProvider(
                        client_id=os.environ.get("FACEBOOK_CLIENT_ID"),
                        client_secret=os.environ.get("FACEBOOK_CLIENT_SECRET"),
                        redirect_uri=os.environ.get("FACEBOOK_REDIRECT_URI")
                    )
                }
            )
        )
    ],
    controllers=[AppController],
    providers=[AppService]
)
class AppModule:
    ...

app_controller.py

from typing import Annotated

from nestipy.common import Controller, Get, Post, Response, Request
from nestipy.ioc import Inject, Param, Res, Req

from nestipy_socialite import SocialiteService


@Controller('auth')
class AppController:
    socialite: Annotated[SocialiteService, Inject()]

    @Get('/{driver}/login')
    async def get(self, driver: Annotated[str, Param('driver')], res: Annotated[Response, Res()]) -> Response:
        redirect_url = self.socialite.driver(driver).get_authorization_url()
        print(redirect_url)
        return await res.redirect(redirect_url)

    @Get('/{driver}/callback')
    async def callback(
            self,
            req: Annotated[Request, Req()],
            res: Annotated[Response, Res()],
            driver: Annotated[str, Param('driver')],
    ) -> dict:
        code = req.query_params.get('code')
        return self.socialite.driver(driver).user(code=code)

Support

Nestipy is an MIT-licensed open source project. It can grow thanks to the sponsors and support from the amazing backers. If you'd like to join them, please [read more here].

Stay in touch

License

Nestipy is MIT licensed.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nestipy_socialite-0.1.1.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nestipy_socialite-0.1.1-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file nestipy_socialite-0.1.1.tar.gz.

File metadata

  • Download URL: nestipy_socialite-0.1.1.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.13.0 Darwin/23.4.0

File hashes

Hashes for nestipy_socialite-0.1.1.tar.gz
Algorithm Hash digest
SHA256 ed418cd1b6bf42724dfc9ff5ba59be7fb4c7d7c15f028f7e0cd4bcc5fd5cdd76
MD5 6b8f09df79bf66e0f68dbafea90c19b9
BLAKE2b-256 feab29e9bd7b64a850a7ff7569895b6f29929b1e0d5c52cfe5ec005289741ec2

See more details on using hashes here.

File details

Details for the file nestipy_socialite-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: nestipy_socialite-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 10.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.13.0 Darwin/23.4.0

File hashes

Hashes for nestipy_socialite-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 dba423079d91fa026ee68f140b5d6f27c1ce12a6fdcc9fa954c71806c9be86a6
MD5 ecc5df590d3d6a23d06903f8463d5959
BLAKE2b-256 ecdf047698169adbbe3c745dceef043f25ccec45841a7793ae745b1c60eacd38

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page