iOS/macOS/WatchOS/tvOS Swift framework for the YNAB API

I was working on a small personal project for iOS using the YNAB API, and the more I built it, the more I realized it might make sense to break out the API access bits into their own distinct framework.  I ended up quickly pulling that code out and putting it in its own git repository. 

Wanted to share here to get some feedback from anyone who might be using the YNAB API with iOS right now.

 

https://github.com/andrebocchini/swiftynab

 

I also generated some docs if anyone is curious to take a look:

 

https://andrebocchini.github.io/swiftynab

6replies Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
  • Excellent, Hot Pink Tape ! Thanks for your work on this.

    I'm adding your library to our "community-supported libraries" page. I'll post here once that's been deployed (should be tomorrow). Thanks again!

    Reply Like
  • George  Thanks!  That's awesome!

     

    While you're here, just out of curiosity, have you guys noticed/had any problems with the OAuth redirects?  I noticed it not only in the test app I was working on, but also in some of the community apps like "Allowance" on iOS, and "I Would Have Saved" on the web.  The pattern I see is something like this:

     

    1. Call

    https://app.youneedabudget.com/oauth/authorize?client_id=TOKEN_REMOVED&redirect_uri=swiftynab://oauth&response_type=token

    And get the login page as expected

    2. Enter credentials and hit the login button.  Looking at the session it looks like the page calls

    https://app.youneedabudget.com/api/v1/catalog?operation_name=loginUser

    Login is successful and we get a nice JSON response with a whole lot of account information, but no redirect, so we sit on the login page, and to the user it looks like nothing happened at all. 

    3. If at this point you hit refresh on the browser, we'll naturally call the following endpoint a second time

    https://app.youneedabudget.com/oauth/authorize?client_id=TOKEN_REMOVED&redirect_uri=swiftynab://oauth&response_type=token

    4. Since we successfully logged in in step 2, we don't see the login credential fields, and we actually see the page where we get to Authorize the application to access our account.  If we hit the orange authorize button, we see that the page calls

    https://app.youneedabudget.com/oauth/authorize

    And as a response we get the expected 302 redirect.

     

    I'm able to reproduce this consistently, both on iOS and on the web apps.  I captured some sessions if you think there's value in the raw details of the requests and responses, but I didn't post them here because they had a ton of account information.  I'm sure we can figure something out if that's valuable information for troubleshooting. 

     

    If there's nothing wrong on your end, maybe we community developers aren't going through the OAuth flow correctly on our end. 

     

    If you decide to test using the test app in my project, just make sure you open LandingViewController.swift and insert the OAuth client token in there since I removed it before committing the code.

    Reply Like
      • George
      • Developer
      • george_ynab
      • 6 mths ago
      • Reported - view

      Hot Pink Tape I was able to repro locally so we can start working on a fix. This issue is in a section of code that works around an iOS 11 WKWebView bug. It may take some time to get this fix out b/c it touches mobile. I'll keep you posted. Thx for the report.

      Reply Like
  • George Thanks for looking into it.  I'll keep an eye out for updates on this.

    Reply Like
  • Hot Pink Tape - We just released a change that should fix this!  Can you give it a whirl and let us know if you still have trouble?  Thanks!

    Reply Like
    • Brady I just tried it using my test app on iOS, and a couple of the community apps on a desktop browser.  Looks like it's working properly now.  Thanks for the quick fix!

      Reply Like 1
Like Follow
  • 6 mths agoLast active
  • 6Replies
  • 120Views
  • 2 Following