[Python] Auth via Instagram

Discussão em 'Python' iniciado por Stack, Setembro 11, 2024.

  1. Stack

    Stack Membro Participativo

    Could you please help me resolve the "Sorry, this content isn't available right now" issue with Instagram OAuth?

    1. I created an app and obtained client_id & client_secret.
    2. On the front-end, I implemented the redirect:

    const myUrlWithParams = new URL('https://api.instagram.com/oauth/authorize')
    myUrlWithParams.searchParams.append('client_id', '111')
    myUrlWithParams.searchParams.append('redirect_uri', 'https://example.com/auth/instagram/')
    myUrlWithParams.searchParams.append('scope', 'user_profile')
    myUrlWithParams.searchParams.append('response_type', 'code')

    window.location.href = myUrlWithParams.href

    1. On the back-end, I set up a handler for /auth/instagram/:

    # Getting access_token
    request_data = {
    "client_id": "111",
    "client_secret": "222",
    "grant_type": "authorization_code",
    "code": request.GET.get("code"),
    "scope": "user_profile",
    "redirect_uri": "https://example.com/auth/instagram/",
    }
    response = requests.post("https://api.instagram.com/oauth/access_token", data=request_data, proxies=proxies)
    access_token = response.json().access_token

    # Requesting the user profile
    response = requests.get("https://graph.instagram.com/me", data={"access_token": access_token, "fields": "username"})
    print(response.text) # "Sorry, this content isn't available right now"

    1. The access_token is obtained correctly, and the app is active in https://www.instagram.com/accounts/manage_access/.
    2. However, when I make a request to https://graph.instagram.com/me, I get the error "Sorry, this content isn't available right now" (I tried different versions like https://graph.instagram.com/v20.0/me).

    Get fields and edges on a User

    Continue reading...

Compartilhe esta Página