-
Notifications
You must be signed in to change notification settings - Fork 79
Authentication
In order to authenticate Instagram users you have two options ✌️
You can use the included authentication method in SwiftInstagram, which will handle the authentication process for you. Or use your own one and let SwiftInstagram know the access token.
SwiftInstagram uses client side (implicit) authentication, so you must uncheck the option "Disable implicit OAuth" from the Security tab of your Instagram client.
Copy the Client ID from your client and paste it inside your Info.plist
file with InstagramClientId
as the key. Do the same with your redirection URI and the InstagramRedirectURI
key.
let api = Instagram.shared
// Login
api.login(from: navigationController!, success: {
// Do your stuff here ...
}, failure: { error in
print(error.localizedDescription)
})
// Returns whether a user is currently authenticated or not
let _ = api.isAuthenticated
// Logout
api.logout()
You can also specify the login permissions with the optional withScopes
parameter. By default, it is set to .basic
access only, however, you can request multiple scopes at once:
api.login(from: ..., withScopes: [.likes, .comments, .followerList], ... )
As I said, is not mandatory to use the previous method. If you already own an access token you could just use the following:
Instagram.shared.storeAccessToken(<YOUR ACCESS TOKEN>)
Let's go! 😎 Now you can start requesting some data from Instagram.