uber / uber-ios-sdk

Uber iOS SDK (beta)
https://developer.uber.com/docs
MIT License
375 stars 125 forks source link

Are there more robust logs? #146

Closed tylerswartz closed 7 years ago

tylerswartz commented 7 years ago

Hi there, I'm migrating from an oauth sdk to the Uber sdk. I've added the login manager to my custom login button and it successfully checks for the native Uber app (shows the expected error in the console) and then opens the safari view controller. However, once the password is entered, the view controller is dismissed and nothing else happens. Nothing is printed to the console. Is there a way to turn on more robust logging so that I can debug it easier and see where it's failing?

I've doubled checked all of the settings in info.plist and I've confirmed I have the correct methods to handle the callback uri in app delegate (which don't appear to get called).

The previous oauth library I was using is p2_oauth and it has a "verbose" setting that would log in the console almost every action it was taking behind the scenes when it was storing and refreshing the tokens which was super helpful for debugging.

jbrophy17 commented 7 years ago

Hey @tylerswartz unfortunately we do not have any additional logging settings at this time, but that is a good suggestion for an improved debugging experience.

If I am reading you correctly, it sounds like you want to use the Authorization Code fallback for Single Sign On when the native app is not installed. In your completion closure for login, are you receiving any errors?

The one "gotcha" with the Authorization Code flow is that the completion closure will fire with a nil AccessToken and nil Error if it successfully made a request to your server. At that point, your server has the Authorization Code which needs to be exchanged for a token, which you will need to provide back to the app.

This also requires having 2 separate callback uris defined in your info.plist, one for handling the SSO redirect and one that will be used to redirect the Authorization Code to your server

tylerswartz commented 7 years ago

Hi @jbrophy17, thanks for the "gotcha", I now see that it's returning with a nil accessToken.

I don't have a preference of the fallback authorization flow when SSO isn't available. It's unclear in the docs if the Implicit Grant flow allows me to make ride requests. If not, then the Authorization Code flow is probably the best fallback.

Do you have a suggestion of which method I need to call when SSO isn't available? I'm a little confused as to why the SDK doesn't handle the entire authorization and token exchange process and account for when SSO isn't available. It appears that if the accessToken is returned nil that I then need to do a separate call to exchange the tokens. I'm not sure which call that is. Thanks for the help.

jbrophy17 commented 7 years ago

Yes, if you want to make ride requests via the API you will need to use Authorization Code flow as the fallback, since the ride request scope is privileged (more info available here)

Currently the SDK does not handle getting the access token back from your server, so, when the accessToken is returned nil, that indicates that your server has gotten the Authorization Code. Once your server exchanges that for an access token, you will have to make a separate call from your app to your server to get that token. Making this process more seamless sounds like it would be useful, so I'd ask that you open a separate issue as a feature request

tylerswartz commented 7 years ago

Ok, thanks for confirming. For now, I've added in logic to stop .Native from falling back to the .AuthorizationCode flow so that I can transition to my previously used oauth library that presents the SafariViewController and handles the token exchange. I'll create two separate feature request issues.