Custom URL on iOS

Is there a way to achieve this in Xojo for iOS, for the purpose of Oauth 2.0 redirect URL authorization?

http://iosdevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html

[quote=165401:@Jonathan L]Is there a way to achieve this in Xojo for iOS, for the purpose of Oauth 2.0 redirect URL authorization?

http://iosdevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html[/quote]

Yes I have done this in a test iOS app thus far using xojo.Net.HTTPSocket class I made. You just have to know the oAuth 2.0 process.

Thanks Mike -

So you created a HTTPSocket … how did you refer to it in code as the redirect URL? simply as http://localhost ? with a port number?

Thank you!

[quote=165403:@Jonathan L]Thanks Mike -

So you created a HTTPSocket … how did you refer to it in code as the redirect URL? simply as http://localhost ? with a port number?

Thank you![/quote]

Sorry I was editing and got locked out :slight_smile:

I used HTML Viewer to gain the Access Code via the URL Redirect. Once that was complete I used the sockets.

[quote=165403:@Jonathan L]Thanks Mike -

So you created a HTTPSocket … how did you refer to it in code as the redirect URL? simply as http://localhost ? with a port number?

Thank you![/quote]

I used the HTMLViewer DocumentComplete event to catch the redirected URL, but atleast on OS X there is an issue with OS X not giving you the redirect URL immediately. I solved this by forcing a javascript reload and then received the redirected URL with my access code at that point.

This should give you the PROCESS to complete the oAuth 2.0 authorization when having to use a custom URL to gain the oAuth Access Token, but this was for desktop.You will just need to adapt the sockets to use the Xojo.Net.HTTPSocket etc.

https://github.com/IntelligentVisibility/DropboxAPI

Also:
http://developer.xojo.com/httpsocket

Finally it just depends which API you are trying to use oAuth 2.0 wise. I also use Cisco API’s using oAuth and luckily then don’t require a web site URL based redirect access code negotiation like Dropbox does (see https://www.dropbox.com/developers/core/docs#oa2-authorize). With Cisco’s API for example I just used native httpsockets the whole way.

Thanks for sharing your code, Mike, I’ll have to see how you implemented it :slight_smile:

I used a webview delegate and caught the initial redirected URL using the CancelLoad event and parsed the url for the authorization code. That part wasn’t the problem - the problem is submitting the authorization code by POST via a curl form to obtain an access token. I’m trying to do that via HTTPSocket but the server is returning an error on the redirect uri.

[quote=165406:@Jonathan L]Thanks for sharing your code, Mike, I’ll have to see how you implemented it :slight_smile:

I used a webview delegate and caught the initial redirected URL using the CancelLoad event and parsed the url for the authorization code. That part wasn’t the problem - the problem is submitting the authorization code by POST via a curl form to obtain an access token. I’m trying to do that via HTTPSocket but the server is returning an error on the redirect uri.[/quote]
Which API or is it private?

… to get the auth code? setDelegate in UILib

:slight_smile: No the destination oAuth site. Is it a public API service or private?

private

[quote=165406:@Jonathan L]Thanks for sharing your code, Mike, I’ll have to see how you implemented it :slight_smile:

I used a webview delegate and caught the initial redirected URL using the CancelLoad event and parsed the url for the authorization code. That part wasn’t the problem - the problem is submitting the authorization code by POST via a curl form to obtain an access token. I’m trying to do that via HTTPSocket but the server is returning an error on the redirect uri.[/quote]

It is perfectly feasible to set a page not to be accessed directly, but only through the redirect. Or only by a browser, or only when a certain session cookie is present. I would start by verifying the target of the redirect is accessible directly. If it works, maybe what your HTTPSocket needs is to have the same headers as the browser.