Snapchat login Kit with python

97 Views Asked by At

I'm trying to generate a Oauth URL with python and able to generate but when I hit the URL from Snap I'm getting only "Something went wrong" and no other message or error... Snapchat login window

Below is my snapchat with python code

from urllib.parse import urlencode, quote


SNAPCHAT_API_KEY = "#####################"
SNAPCHAT_API_SECRET = "##################"

SNAPCHAT_OAUTH_CALLBACK_URL = "https://localhost:3000"


class SnapchatAPI:
    
    def __init__(self):
        self.api_key = SNAPCHAT_API_KEY
        self.api_secret = SNAPCHAT_API_SECRET
        self.oauth_callback_url = SNAPCHAT_OAUTH_CALLBACK_URL
        self.permissions = ["display_name", "external_id"]
        self.auth_url = "https://accounts.snapchat.com/accounts/oauth2/auth"

    def snapchat_login(self):
        try:
            query_param_string = urlencode(
                {
                    "client_id": self.api_key,
                    "redirect_uri": self.oauth_callback_url,
                    "response_type": "code",
                    "scope": " ".join(self.permissions),
                },
                quote_via=quote,
            )

            # if state:
            #     query_param_string += f"&state={state}"

            return f"{self.auth_url}?{query_param_string}"
        
        except Exception as e:
            print(e)
            return None

The url that I'm getting is...

https://accounts.snapchat.com/accounts/oauth2/auth?client_id=##############&redirect_uri=https%3A%2F%2Flocalhost%3A3000%2Ftwitter&response_type=code&scope=display_name%20external_id

What is the issue here and how can I fix it? Alternatively is there a better way to implement Login with Snapchat with python?

0

There are 0 best solutions below