5

I'm reading Uber's sdk/api doc but I am a rookie and I don't know what the redirectURL should be. Is it a given url from Uber? Because I couldn't find it. Or is it an url for a webpage customized by app developer deployed their own server/local machine? If so, how should I write it?

Totally confused on this point.

Please help with some details as possible.

Many thanks!

bolizhou
  • 1,208
  • 1
  • 13
  • 31

3 Answers3

3

Here I solved this problem. Actually I was confused that if the redirect url is a url for web site on some server, then the architect would be quite complex and there seems to be no way to identify which authorization code is for which app client.

Now I think I'm clear since I read @Romain's comment here, and now I know that the redirect url can be an url of opening your ios app (I'm sure it works for android and others).

For instance, if your ios app's URL schema/name is: myapp, then the redirect url can be like this:

myapp://oauth/callback

then once user authorizes your app, the redirect url (in this case it's redirecting to your app) will be opened; and in the AppDelegate.m one of the callback delegate methods:

-(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation 

will capture the redirect url with the authorization code sent from Uber; if you print it you would see something like this:

myapp://oauth/callback?code=YOURCODE

So the code can be well received by the correct app.

Community
  • 1
  • 1
bolizhou
  • 1,208
  • 1
  • 13
  • 31
  • @SANDEEP what you do mean by token? if you are talking about server token, it was generated by uber if you registered your app on uber's developer's dash board. – bolizhou Nov 24 '16 at 06:32
2

The API interaction initiates as follows:

  1. The concerned request is redirected to Uber API,
  2. API authorizes the action
  3. API redirects user to a Custom page of your website, with a GET parameter that will contain all needed information sent by API.

So, basically, redurect URL is the page of your website that does the job once the user is authenticated via Uber API.

See more at official doc

Grigory Kornilov
  • 366
  • 2
  • 4
  • 17
  • Thanks for your quick respond! But I still don't understand how the redirect custom page would help with my app. I mean what is the difference with or without this custom page? – bolizhou Jun 30 '15 at 01:20
  • What's your exact purpose of using Uber API? – Grigory Kornilov Jun 30 '15 at 10:11
  • So, I tried this, I put the "https://github.com" in the redirect URL as well as the policy URL. And then when I pressed login, my app redirected me to open safari and Uber would ask if some scopes of user info can be accessed by my app. After I pressed agree, it redirected me to github.com as I put it as redirect URL earlier. So I know when the custom redirect page would show up now. But I still don't know what should happen after my redirect page shows. Please guide, thanks. – bolizhou Jun 30 '15 at 10:14
  • Hi Grigory Kornilov, I wanted to use Uber API to request a real ride and also fetch user's profile, so I think I have to pass the OAuth2.0, but I'm not sure what redirect URL is doing here. – bolizhou Jul 01 '15 at 01:20
  • Thing is, if you put a custom page of your website in redirect URL, it will receive a special "token" that will enable you to use some user information (actually, act for a short time on behalf of the authenticated user). Thus, you will be able to use this token to ask Uber API for this user's data, and use it. See the official doc I've linked above, especially steps 2,3,4 – Grigory Kornilov Jul 01 '15 at 12:47
  • Thanks for your explanation! Another question if you don't mind, so basically, I need to develop more than just an app, I need to get myself a server for redirect, right? – bolizhou Jul 02 '15 at 08:28
  • Yes, most applications use web servers to work with data. For example, "generally", an application cannot do a database call: you need a webserver that will do it instead and send data to the app. You can start with a cheap virtual server (something around 30$ per year with a domain name included) – Grigory Kornilov Jul 02 '15 at 08:52
  • Thanks for your explanation here, so I need a webserver to receive the authorize code from Uber and then send this code to my app so my app can exchange for the access_token with it, right? If so, then what if I have many clients and my webserver would receive many codes accordingly. How could my webserver tell which code is for which client and send them to the right app client? – bolizhou Jul 03 '15 at 07:14
  • Unfortunately, it's not possible to determine whether you really need a server or not, accordingly to your description. This kind of questions is subject to studies in IT atchitecture, and thus may not be explained and justified in a SO topic... srry – Grigory Kornilov Jul 03 '15 at 07:28
  • The identification of client apps on the server may be done via sessions, business logic, database, etc depending on your architecture choices. But the question is way too large – Grigory Kornilov Jul 03 '15 at 07:29
  • Yeah, but the authorization code is sent from Uber server endpoint which is invisible to me, there is no way I can identify which code is for which app client if the code itself was generated randomly or encrypted. – bolizhou Jul 03 '15 at 07:50
0

Redirect url is actually an url of opening your app. The official documentation has good insight in this regard.Read it here.

GmisraG
  • 79
  • 4