0

I succesfully managed to login and logout instagram users in my application, but i want to create a new django user on first login, like "Register with Instagram", storing user tokens etc. to use their photos and data in my app

I'm totally new to python-social-auth, any tips on how to achieve this?

Doc
  • 5,078
  • 6
  • 52
  • 88

1 Answers1

0

If you did everything(migrations) correctly, all those things are stored for you.

Here is how you can access access_token:

social_auth = UserSocialAuth.objects.get(user_id=id, provider='instagram')

access_token = social_auth.access_token

Then, you can use this access_token to access their photo and etc like this:

instagram_api = InstagramAPI(
        access_token=access_token,
        client_secret=INSTAGRAM_CLIENT_SECRET)

instagram_posts, next_ = instagram_api.user_recent_media(
            user_id=id, count=33)

Hope it helps

Jahongir Rahmonov
  • 13,083
  • 10
  • 47
  • 91