Skip to content

Instantly share code, notes, and snippets.

@hansemannn
Last active February 13, 2018 20:07
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save hansemannn/71b6181557ec0f6024e29c642dbe52e3 to your computer and use it in GitHub Desktop.
Save hansemannn/71b6181557ec0f6024e29c642dbe52e3 to your computer and use it in GitHub Desktop.
Use Axway Hyperloop to perform OAuth-sessions with the iOS 11+ API "SFAuthenticationSession"
const SFAuthenticationSession = require('SafariServices/SFAuthenticationSession');
const NSURL = require('Foundation/NSURL');
const session = SFAuthenticationSession.alloc().initWithURLCallbackURLSchemeCompletionHandler(
NSURL.alloc().initWithString('https://github.com/login/oauth/authorize?scope=repo&client_id=XXXXX'),
'appcgithub://',
function(url, error) {
if (error != null) {
Ti.API.error('Error performing OAuth: ' + error.localizedDescription);
cb({ success: false, error: 'Error performing OAuth: ' + error.localizedDescription });
return;
}
cb({ success: true, url: url.absoluteString });
});
function cb(e) {
Ti.API.info(e);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment