TheM4hd1 / SwiftyInsta

Instagram Private API Swift

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to get Access token after user logs in to instagram?

AwaisFayyaz opened this issue · comments

I have checked the Authentication.response but could not find a property through which i can get my hands on access Token? is this possible with Swifty Insta to get Access token after the login?

Save it somewhere. In the readme you can find ex how to store it in user defaults.

Hey @AwaisFayyaz,

If this is about caching cookies, you should use .persist() on your Authentication.Response, save the returned String in UserDefaults (or similar), and then use that string to retrieve the response on your next launch with Authentication.Response.persisted(with:).

Although easier, you should not follow @borisdipner's advice: storing cookies in UserDefaults should be avoided at all costs, being a serious security concern.
I also know the README.md suggests that (I wrote that so I know hahaha), but please don't do it.

Hi @sbertix . Thanks for the reply.
I am already using the .persist() function from the sample code on readme with heading LoginWebViewController (>= iOS 12 only) and its working fine. I can get the user details and followers API also working. So, the flow seem to be working fine.

I am looking to get access token after the login which looks something like this
IGQVXXXXXXXXXXXpsVnhPcjJoLUZApdUFSdHFjc1FOdmN2QU1mT2ZAYdnBqd2x2NDcxRXFUN3ZAQLUZAuVzFUNkVQMGlOYmRHeEQ4ZADM1RExlWUJMblowZAzhPbDRFRXV4Q3ZAkRG9DR0NVMjM2ejRDQUQ5MkFCVXXXXXXXXXXX.

So, using instagram Basic display, i can get the above access token using this API https://api.instagram.com/oauth/access_token
passing the required parameters such as client_id, client_secret, code, grant_type, and redirect_uri

I need to send this access token to Backend. But in Swifty Insta, i could not find any property which gives me the access token after login. am i missing something?

SwiftyIntsa uses Private API, access_token belongs to to official API. The Private API is the one that Instagram's app is using. It's the reversed version of official app's api

Thanks for the reply @TheM4hd1
Any way i can get my hands on access token using this private API?

Private API doesn't rely on access_token, so No, there is no way to get access_token since it doesn't exists in private api

Thanks for the clarification @TheM4hd1 .Much appreciated.
And Finally, Can you point me towards some resource through which i can learn more about the private API?