Swiftyinsta: Login stopped working

Created on 23 Jul 2020  ·  12Comments  ·  Source: TheM4hd1/SwiftyInsta

Authenticating with cache or via LoginWebViewController fails with error:
"https://i.instagram.com/api/v1/accounts/current_user/.\nInvalid response.\nProcessing handler returned nil.\n405"

bug

Most helpful comment

Thank you @alperalb , I've updated the code in 2.3.3.\
Please keep in mind, though, that SwiftyInsta is no longer being actively maintained, so while this was an easy fix, it might stop working in the future.

All 12 comments

Change UsersHandler CurrentUser method from post to get

func current(delay: ClosedRange<Double>?, completionHandler: @escaping (Result<User, Error>) -> Void) { guard let storage = handler.response?.storage else { return completionHandler(.failure(GenericError.custom("InvalidAuthentication.ResponseinAPIHandler.respone`. Log in again.")))
}
// let body = ["_uuid": handler.settings.device.deviceGuid.uuidString,
// "_uid": storage.dsUserId,
// "_csrftoken": storage.csrfToken]

    requests.request(User.self,
                     method: .get,
                     endpoint: Endpoint.Accounts.current,
                     //body: .parameters(body),
                     delay: delay,
                     process: { User(rawResponse: $0.user) },
                     completion: completionHandler)
}`

Change UsersHandler CurrentUser method from post to get

func current(delay: ClosedRange<Double>?, completionHandler: @escaping (Result<User, Error>) -> Void) { guard let storage = handler.response?.storage else { return completionHandler(.failure(GenericError.custom("InvalidAuthentication.ResponseinAPIHandler.respone`. Log in again.")))
}
// let body = ["_uuid": handler.settings.device.deviceGuid.uuidString,
// "_uid": storage.dsUserId,
// "_csrftoken": storage.csrfToken]

    requests.request(User.self,
                     method: .get,
                     endpoint: Endpoint.Accounts.current,
                     //body: .parameters(body),
                     delay: delay,
                     process: { User(rawResponse: $0.user) },
                     completion: completionHandler)
}`

I tried it based on your solution, but it doesn't seem to work

Change UsersHandler CurrentUser method from post to get
func current(delay: ClosedRange<Double>?, completionHandler: @escaping (Result<User, Error>) -> Void) { guard let storage = handler.response?.storage else { return completionHandler(.failure(GenericError.custom("InvalidAuthentication.ResponseinAPIHandler.respone`. Log in again.")))
}
// let body = ["_uuid": handler.settings.device.deviceGuid.uuidString,
// "_uid": storage.dsUserId,
// "_csrftoken": storage.csrfToken]

    requests.request(User.self,
                     method: .get,
                     endpoint: Endpoint.Accounts.current,
                     //body: .parameters(body),
                     delay: delay,
                     process: { User(rawResponse: $0.user) },
                     completion: completionHandler)
}`

I tried it based on your solution, but it doesn't seem to work

This one is working for me..
If you are using pods, you might need to re-build the project, cleaning all first (command-shift-K) or cleaning derived data.
Changed lines is in UserHandler.swift file, starting on line 13

Change UsersHandler CurrentUser method from post to get

func current(delay: ClosedRange<Double>?, completionHandler: @escaping (Result<User, Error>) -> Void) { guard let storage = handler.response?.storage else { return completionHandler(.failure(GenericError.custom("InvalidAuthentication.ResponseinAPIHandler.respone`. Log in again.")))
}
// let body = ["_uuid": handler.settings.device.deviceGuid.uuidString,
// "_uid": storage.dsUserId,
// "_csrftoken": storage.csrfToken]

    requests.request(User.self,
                     method: .get,
                     endpoint: Endpoint.Accounts.current,
                     //body: .parameters(body),
                     delay: delay,
                     process: { User(rawResponse: $0.user) },
                     completion: completionHandler)
}`

Thank you @alperalb , work for me.

Change UsersHandler CurrentUser method from post to get
func current(delay: ClosedRange<Double>?, completionHandler: @escaping (Result<User, Error>) -> Void) { guard let storage = handler.response?.storage else { return completionHandler(.failure(GenericError.custom("InvalidAuthentication.ResponseinAPIHandler.respone`. Log in again.")))
}
// let body = ["_uuid": handler.settings.device.deviceGuid.uuidString,
// "_uid": storage.dsUserId,
// "_csrftoken": storage.csrfToken]

    requests.request(User.self,
                     method: .get,
                     endpoint: Endpoint.Accounts.current,
                     //body: .parameters(body),
                     delay: delay,
                     process: { User(rawResponse: $0.user) },
                     completion: completionHandler)
}`

I tried it based on your solution, but it doesn't seem to work

This one is working for me..
If you are using pods, you might need to re-build the project, cleaning all first (command-shift-K) or cleaning derived data.
Changed lines is in UserHandler.swift file, starting on line 13

Thanks, I clear the derived data and it works normally.

Thank you @alperalb , I've updated the code in 2.3.3.\
Please keep in mind, though, that SwiftyInsta is no longer being actively maintained, so while this was an easy fix, it might stop working in the future.

Thanks for the fast update. It’s pretty sad that it’s not actively maintained though, imho it is the best swift Instagram framework at the moment and it would be a waste to let it die.

@sbertix happy to help with maintenance. Where is the announcement?

Had to use pod 'SwiftyInsta', :git => 'https://github.com/TheM4hd1/SwiftyInsta', :branch => 'master'

@sbertix is the release tagged?

Thanks for the fast update. It’s pretty sad that it’s not actively maintained though, imho it is the best swift Instagram framework at the moment and it would be a waste to let it die.

There were too many "issues" with the current implementation, requiring a completely clean slate going forward @biox86

When I wrote SwiftyInsta 2.0, I did it in a way so it'd still be "authentic" to the original implementation, which was basically a porting.

Swift changed a lot since then and a lot of features can simply not be added to the codebase, e.g. cancelling a request, multi-storage support for authentication responses, a working username and password authentication, Combine support, custom authentication, etc.

So, I started a new project using modern Swift, Swiftagram, easier to use and capable of fixing all of the issues above. Starting from scratch truly was a necessity.

@sbertix happy to help with maintenance. Where is the announcement?

No official announcements. I would remind people every once in a while when new issues were sent in.

As I'm working on Swiftagram, I'm still going be to fixing critical issues (like this one), but I won't be pushing new features or enhancements here (for instance I'm not gonna port Swiftagram BasicAuthenticator for a working non-web view based login, or its Combine features).

If you are invested in SwiftyInsta, and want to contribute through PRs, and keeping this active, you're more than welcome @mycroftcanner

Had to use pod 'SwiftyInsta', :git => 'https://github.com/TheM4hd1/SwiftyInsta', :branch => 'master'

@sbertix is the release tagged?

Yep. Everything tagged and pod version updated… 🤔
I'm not sure why it'd do that.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sbertix picture sbertix  ·  8Comments

canaksoy picture canaksoy  ·  6Comments

sbertix picture sbertix  ·  3Comments

trentona picture trentona  ·  3Comments

rmelnik7777 picture rmelnik7777  ·  19Comments