iMerica / dj-rest-auth

Authentication for Django Rest Framework
https://dj-rest-auth.readthedocs.io/en/latest/index.html
MIT License
1.67k stars 312 forks source link

Is Google scope for Youtube DataAPI supported? #2846 #250

Closed rollue closed 3 years ago

rollue commented 3 years ago

Asked the same question on django-allauth, but leaving it here too as I don't know where the problem comes from.

# settings.py
SOCIALACCOUNT_PROVIDERS = {
    "google": {
        # For each OAuth based provider, either add a ``SocialApp``
        # (``socialaccount`` app) containing the required client
        # credentials, or list them here:
        "APP": {
            "client_id": env("SOCIAL_AUTH_GOOGLE_OAUTH2_KEY"),
            "secret": env("SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET"),
        },
        "SCOPE": [
            "profile",
            "email",
            "https://www.googleapis.com/auth/youtube",
            # or "youtube", "profile", "email"? - but it's not working too
        ],
    }
}

I tried with the above settings to include Youtube DataAPI to my app's scope as described here in the doc, but it keeps returning access_tokens without the right permission to access Youtube DataAPI. Is this even supported?

Python-social-core supports this with the below settings(I have tested it). By the way the email and profile scopes work, but it seems the youtube-related scope gets ignored.

SOCIAL_AUTH_GOOGLE_OAUTH2_SCOPE = [
    "email",
    "profile",
    "https://www.googleapis.com/auth/youtube",
]

I was trying to migrate to django-allauth+dj_rest_auth from python-social-core but if this is not supported, I have to go back :( Any ideas? Thanks.

rollue commented 3 years ago

Closing as our client dev passed on the scope params and it worked fine.