When I build and deploy to device I get a class not found. It seems to work under ripple. Looks to me like a plugin definition error. I tried adding that plugin manually, but not much luck. Any pointers?
Were you able to get this working? I didn’t get a class not found error, however I could not get the popup method to display a login screen if I used it as a normal Angular service.
I didn’t get it working. I think there is a structural difference between using the Ionic tools and the cordova ones. The example Cordova app works with oauth.io, but the Ionic version does not. It would be great to get it working but I punted it after tearing my hair out a while.
How did you go about? Is there anything you need to configure to get it to work or is it just to follow the steps?
I’ve tried a couple of times now but getting stuck on OAuth being undefined in my controller.
As with most things Angular, I broke it out into separate services etc… so my security service deals with the user auth in this gist: https://gist.github.com/battlecow/8ccdd4501932b2b723ac while I dynamically create and return the OAuth library based on whether the device is a phone or regular web browser in this gist: https://gist.github.com/battlecow/8e54e8985d214eaa7a3f
Then just install the plugin as you install any plugin and you should be able to get the /me to return your user info. If you need any other help let me know.
EDIT my original second gist link broke, I corrected it with a new one.
I just tried for several hours to get the OAuth plugin working in my Ionic app. I am using cordova version 3.5.0 and installed the plugin via plugin install ... etc.
I googled for several hours and could not find the root of my problem.
Even if try to bypass angular by just inserting this code into one of my js files, included after the cordova.js of course, it still says Uncaught ReferenceError: OAuth is not defined.
I also removed and added my android platform several times now.
can anyone point me into the right direction? Should I try someting else to see if the plugin works with ionic / cordova?
Any help is appreciated. I would be pulling my hair out, if I had some left…
Have a look at my second gist, I just corrected it to be a valid gist. I was having an issue on the timing of loading the oauth lib so I am using $q.when and also referencing the global window object (I need to change that to $window actually) to ensure it is loaded by making it a promise. Let me know if that helps out or if you have any other questions.
@Norwill Here’s a quick plunker of my code, you will have to put in your public key for oauth service. It isn’t quite working right now either, the popup shows up but the result never comes through so I would take the plunkr example and run it on your dev box. – http://plnkr.co/edit/HV8vex4dyAWLJBwfI5xh?p=preview
@fantapop I think wrapping most of these external things is the Angular way to go, this way you can test and inject them as needed.
@Norwill Not sure why you’re code isnt executing? I just updated my plnkr to use a real oauth.io key and a facebook app. The app apparently isn’t setup correctly for logins on the facebook side of things, and it’s getting late here, but you can see that it loads a popup window as it should. Make sure you are allowing your domains on the plnkr side and oauth.io on the facebook side.
@battlecow The application on facebook and Oauth is configured OK, and when i test the code of aouth in the browser works perfectly but your code doesn’t work on the browser or device (iPhone 4S).
I test your code on another app scratch and show a message like this:
Cannot find hostname in http:/// static
code InvalidHeader
message Cannot find hostname in http:/// static.
@Norwill Yea that would be the issue where your phone app is pulling in the web version of the js sdk for oauth. In my example on line 7 of the oauth.js file, I comment out my check for mobile vs desktop and just return false. Try uncommenting that section and removing the return false line.