Kodeco Forums

OAuth 2.0 with Swift Tutorial

OAuth 2.0 is a tricky subject. In this tutorial you will learn how to use OAuth2 in an iOS app, in 3 different ways.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/1757-oauth-2-0-with-swift-tutorial

Dear ckrych,
I’m new to swift and learn a lot from your tutorials.
https://www.raywenderlich.com/99431/oauth-2-with-swift-tutorial
With the link in the first line under Getting Started I downloaded the project. But many bugs in it. Hard for me to understand them.
Will you please check it or make some explains to me? Thank you very much.

The tutorial was written with old version of Swift language, of which new features like error handling has not been introduced.

To fix the compile errors, you may remove the AeroGearOAuth2’s version in the pod file, and then pod update to get the latest version.

Hope it helps!

Okay. This tutorial is unfortunately way out of date. It should be pulled. No one can learn anything from this. If you don’t already know what you are doing, then you won’t get anywhere. Just to get the starter projects working, you have update the pod files, there is no indication on how to do that. Then you find that the Swift code in view controller has to be updated to try and match the new Aerogear or OAuth versions. I didn’t even get to the AFO manager because this tutorial requires such major surgery, it loses relevance and becomes a debugging project. I am no expert on OAuth, but that is why I was going through this tutorial in the first place!

This should be pulled off the site. So many other wonderful tutorials…

1 Like

@jcedman Good news! I’m working on an update for this tutorial.
I’ll simplify it and bring it up to date.

Great Tutorial!!! I’m trying to use the similar methods to authenticate to Cisco Spark APIs and having issues with the redirect URL format. Cisco doesn’t allow the redirect URL format other than http or https when I configure the app on the Cisco side. I tried to configure it with something like sparkapp://oauth-callback/spark but it didn’t save changes in the Spark app settings. I can only set the URL like Recenzje, Gry, Rozrywka, Październik 2022.

Is there a way to use the https url format and still redirect it to the iOS app?

Thanks for your help.

Hardeep.

Does anyone have a link to a tutorial that does not use third party libraries?

@ckrych ckrych can you please send me an updated version of this project? It would be really handy for me!

Thanks!

I tried removing the version number and updating the pod file and sadly it doesn’t work.

aerogear-ios-http appears not to work using latest swift syntax as one of the dependency libraries aerogear-ios-http appears not to be compatible Swift 2.3 . There is a pending pull request for the library, but I agree that this tutorial should probabyl be pulled and updated.

The Google API site has changed dramatically from the description in this tutorial as well, which makes getting started using the tutorial more of an exercise in mapping new manifestation to old documentation, rather than learning the ins & outs of OAuth. Is there any date in mind for the updated version that the author mentioned?

I would love to see a tutorial on how to implement a sign in with instagram since there aren’t to many of tutorials for this around! Hope this can be done

I hope this tutorial can be updated for Swift 3.0 and iOS 10. That would be very helpful.

1 Like

Is the update still happening for this tutorial? :slight_smile: Looks like it would be really great to learn this stuff!

Hi everyone, I’ve upgrade the project to xCode 8 and swift 3.0 compatible.

Thanks for the update, but the imagePickerController delegate method in the ViewController class is declared as private. I had to remove “private” for the callback to work.

Thank you for this tutorial. Could you please provide something like this for macOS? I tried to to everything exactly like this, but on macOS, when I open a url which the open my url scheme, a new window of my app is opened and nothing happens. Instead of this I want to redirect url scheme to already opened window, if one is already available.
Thanks in advance to everybody.

Hi,
first of all i would like to thank you for this tutorial. even though it’s a bit out of date it was very helpful for me.

the first (AeroGearOAuth2) worked fine for me, but i’m struggling on the second implementation (OAuthSwift).
there i have to create an OAuth2Swift object with consumerKey AND consumerSecret.

when registering the App at Google-API you suggested to create OAuth-Credentials by selecting iOS as type, but if i do so i only get an client-Id, but no clientSecret from google.

thanks for advise

This tutorial is more than six months old, so questions are no longer supported at the moment for it. We will update it as soon as possible. Thank you! :]