Code Monkey home page Code Monkey logo

oauth-phonegap's People

Contributors

amitaibu avatar bumpmann avatar mahmoudajawad avatar pplewa avatar thevinc avatar thyb avatar william26 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

oauth-phonegap's Issues

How to send CSRF information to the server?

How do I ensure that the proper csrf information is sent to the server? Currently my login handler looks like this:

  var app = angular.module('app');

  app.controller('LoginCtrl', function($scope, $state, UserService, $http, $cookies) {
    OAuth.initialize('LONG_STRING');
    var token = null;
    $http.get('http://api.example.com/oauth/token')
    .success(function(generatedToken, status) {
      return token = generatedToken;
    }).error(function(errorMessage, status) {
      return console.log("l8 LoginCtrl\n " + status + ": " + errorMessage);
    });

    // fired when touches the Google login button
    $scope.googleLogin = function() {
      return OAuth.popup('google', {
        cache: false,
        state: token
      }).done(function(result) {
        // so far so good, but this is where the request is invalid
        $http.post("http://api.example.com/oauth/signin")
        .success(function(data, status) {
          debugger;
        }).error(function(data, status) {
          debugger;
        });
      }).fail(function(error) {
        return console.log('error: ', error);
      });
    };

It's when I send a POST request to /oauth/signin that my server is unhappy:
ForbiddenError: invalid csrf token

My express server code looks like this:

  var MongoStore, app, bodyParser, compress, connectAssets, contactController, cookieParser, csrf, csrfProtection, errorHandler, express, expressValidator, flash, homeController, logger, methodOverride, mongoose, multer, oauth, parseForm, passport, passportConf, path, secrets, session, userController;

  express = require('express');

  cookieParser = require('cookie-parser');

  csrf = require('csurf');

  compress = require('compression');

  session = require('express-session');

  bodyParser = require('body-parser');

  logger = require('morgan');

  errorHandler = require('errorhandler');

  methodOverride = require('method-override');

  multer = require('multer');

  MongoStore = require('connect-mongo')(session);

  flash = require('express-flash');

  path = require('path');

  mongoose = require('mongoose');

  passport = require('passport');

  expressValidator = require('express-validator');

  connectAssets = require('connect-assets');

  oauth = require('oauthio');

  csrfProtection = csrf({
    cookie: true
  });

  parseForm = bodyParser.urlencoded({
    extended: false
  });

  homeController = require('./controllers/home');

  userController = require('./controllers/user');

  contactController = require('./controllers/contact');

  secrets = require('./config/secrets');

  passportConf = require('./config/passport');

  app = express();

  mongoose.connect(secrets.db);

  mongoose.connection.on('error', function() {
    console.error('MongoDB Connection Error. Please make sure that MongoDB is running.');
  });

  app.set('port', process.env.PORT || 3000);

  app.set('views', path.join(__dirname, 'views'));

  app.set('view engine', 'jade');

  app.use(compress());

  app.use(connectAssets({
    paths: [path.join(__dirname, 'public/css'), path.join(__dirname, 'public/js')]
  }));

  app.use(logger('dev'));

  app.use(bodyParser.json());

  app.use(multer({
    dest: path.join(__dirname, 'uploads')
  }));

  app.use(expressValidator());

  app.use(methodOverride());

  app.use(cookieParser('secret'));

  app.use(session({
    resave: true,
    saveUninitialized: true,
    secret: secrets.sessionSecret,
    store: new MongoStore({
      url: secrets.db,
      autoReconnect: true
    })
  }));

  app.use(passport.initialize());

  app.use(passport.session());

  app.use(flash());

  app.use(csrf(), function(req, res, next) {
    res.cookie('XSRF-TOKEN', req.csrfToken());
    return next();
  });

  app.use(function(req, res, next) {
    res.locals.user = req.user;
    return next();
  });

  app.use(express["static"](path.join(__dirname, 'public'), {
    maxAge: 31557600000
  }));


/* I'm not using any of this right now
  app.get('/', homeController.index);

  app.get('/login', userController.getLogin);

  app.post('/login', userController.postLogin);

  app.get('/logout', userController.logout);

  app.get('/forgot', userController.getForgot);

  app.post('/forgot', userController.postForgot);

  app.get('/reset/:token', userController.getReset);

  app.post('/reset/:token', userController.postReset);

  app.get('/signup', userController.getSignup);

  app.post('/signup', userController.postSignup);

  app.get('/contact', contactController.getContact);

  app.post('/contact', contactController.postContact);

  app.get('/account', passportConf.isAuthenticated, userController.getAccount);

  app.post('/account/profile', passportConf.isAuthenticated, userController.postUpdateProfile);

  app.post('/account/password', passportConf.isAuthenticated, userController.postUpdatePassword);

  app.post('/account/delete', passportConf.isAuthenticated, userController.postDeleteAccount);

  app.get('/account/unlink/:provider', passportConf.isAuthenticated, userController.getOauthUnlink);
*/

  app.get('/oauth/token', csrfProtection, function(req, res) {
    var token = oauth.generateStateToken(req.session);
    return res.send(token);
  });

  app.post("/oauth/signin", parseForm, csrfProtection, function(req, res) {
    var code = req.body.code;
    return oauth.auth("google", req.session, {
      code: code
    }).then(function(request_object) {
      res.send(200, "The user is authenticated");
    }).fail(function(e) {
      console.log(e);
      return res.send(400, "Code is incorrect");
    });
  });

  app.use(errorHandler());

  app.listen(app.get("port"), function() {
    console.log("Express server listening on port %d in %s mode", app.get("port"), app.get("env"));
  });

  module.exports = app;

Here's the error code:

root@example:~/example-api# node index
Express server listening on port 3000 in development mode
GET /oauth/token 200 24.690 ms - 24
ForbiddenError: invalid csrf token
  at verifytoken (/root/example-api/node_modules/csurf/index.js:263:11)
  at csrf (/root/example-api/node_modules/csurf/index.js:93:7)
  at Layer.handle [as handle_request] (/root/example-api/node_modules/express/lib/router/layer.js:82:5)
  at trim_prefix (/root/example-api/node_modules/express/lib/router/index.js:302:13)
  at /root/example-api/node_modules/express/lib/router/index.js:270:7
  at Function.proto.process_params (/root/example-api/node_modules/express/lib/router/index.js:321:12)
  at next (/root/example-api/node_modules/express/lib/router/index.js:261:10)
  at /root/example-api/node_modules/express-flash/lib/express-flash.js:31:7
  at /root/example-api/node_modules/express-flash/node_modules/connect-flash/lib/flash.js:21:5
  at /root/example-api/node_modules/express-flash/lib/express-flash.js:22:5
  at Layer.handle [as handle_request] (/root/example-api/node_modules/express/lib/router/layer.js:82:5)
  at trim_prefix (/root/example-api/node_modules/express/lib/router/index.js:302:13)
  at /root/example-api/node_modules/express/lib/router/index.js:270:7
  at Function.proto.process_params (/root/example-api/node_modules/express/lib/router/index.js:321:12)
  at next (/root/example-api/node_modules/express/lib/router/index.js:261:10)
  at SessionStrategy.strategy.pass (/root/example-api/node_modules/passport/lib/middleware/authenticate.js:318:9)
  at SessionStrategy.authenticate (/root/example-api/node_modules/passport/lib/strategies/session.js:67:10)
  at attempt (/root/example-api/node_modules/passport/lib/middleware/authenticate.js:341:16)
  at authenticate (/root/example-api/node_modules/passport/lib/middleware/authenticate.js:342:7)
  at Layer.handle [as handle_request] (/root/example-api/node_modules/express/lib/router/layer.js:82:5)
  at trim_prefix (/root/example-api/node_modules/express/lib/router/index.js:302:13)
  at /root/example-api/node_modules/express/lib/router/index.js:270:7
  at Function.proto.process_params (/root/example-api/node_modules/express/lib/router/index.js:321:12)
  at next (/root/example-api/node_modules/express/lib/router/index.js:261:10)
  at initialize (/root/example-api/node_modules/passport/lib/middleware/initialize.js:62:5)
  at Layer.handle [as handle_request] (/root/example-api/node_modules/express/lib/router/layer.js:82:5)
  at trim_prefix (/root/example-api/node_modules/express/lib/router/index.js:302:13)
  at /root/example-api/node_modules/express/lib/router/index.js:270:7
  at Function.proto.process_params (/root/example-api/node_modules/express/lib/router/index.js:321:12)
  at next (/root/example-api/node_modules/express/lib/router/index.js:261:10)
  at session (/root/example-api/node_modules/express-session/index.js:386:7)
  at Layer.handle [as handle_request] (/root/example-api/node_modules/express/lib/router/layer.js:82:5)
  at trim_prefix (/root/example-api/node_modules/express/lib/router/index.js:302:13)
  at /root/example-api/node_modules/express/lib/router/index.js:270:7
  at Function.proto.process_params (/root/example-api/node_modules/express/lib/router/index.js:321:12)
  at next (/root/example-api/node_modules/express/lib/router/index.js:261:10)
  at cookieParser (/root/example-api/node_modules/cookie-parser/index.js:34:14)
  at Layer.handle [as handle_request] (/root/example-api/node_modules/express/lib/router/layer.js:82:5)
  at trim_prefix (/root/example-api/node_modules/express/lib/router/index.js:302:13)
  at /root/example-api/node_modules/express/lib/router/index.js:270:7
  at Function.proto.process_params (/root/example-api/node_modules/express/lib/router/index.js:321:12)
  at next (/root/example-api/node_modules/express/lib/router/index.js:261:10)
  at methodOverride (/root/example-api/node_modules/method-override/index.js:77:5)
  at Layer.handle [as handle_request] (/root/example-api/node_modules/express/lib/router/layer.js:82:5)
  at trim_prefix (/root/example-api/node_modules/express/lib/router/index.js:302:13)
  at /root/example-api/node_modules/express/lib/router/index.js:270:7
  at Function.proto.process_params (/root/example-api/node_modules/express/lib/router/index.js:321:12)
  at next (/root/example-api/node_modules/express/lib/router/index.js:261:10)
  at /root/example-api/node_modules/express-validator/lib/express_validator.js:233:12
  at Layer.handle [as handle_request] (/root/example-api/node_modules/express/lib/router/layer.js:82:5)
  at trim_prefix (/root/example-api/node_modules/express/lib/router/index.js:302:13)
  at /root/example-api/node_modules/express/lib/router/index.js:270:7
  at Function.proto.process_params (/root/example-api/node_modules/express/lib/router/index.js:321:12)
  at next (/root/example-api/node_modules/express/lib/router/index.js:261:10)
  at /root/example-api/node_modules/multer/index.js:218:19
  at Layer.handle [as handle_request] (/root/example-api/node_modules/express/lib/router/layer.js:82:5)
  at trim_prefix (/root/example-api/node_modules/express/lib/router/index.js:302:13)
  at /root/example-api/node_modules/express/lib/router/index.js:270:7
  at Function.proto.process_params (/root/example-api/node_modules/express/lib/router/index.js:321:12)
  at next (/root/example-api/node_modules/express/lib/router/index.js:261:10)
  at jsonParser (/root/example-api/node_modules/body-parser/lib/types/json.js:103:37)
  at Layer.handle [as handle_request] (/root/example-api/node_modules/express/lib/router/layer.js:82:5)
  at trim_prefix (/root/example-api/node_modules/express/lib/router/index.js:302:13)
  at /root/example-api/node_modules/express/lib/router/index.js:270:7
  at Function.proto.process_params (/root/example-api/node_modules/express/lib/router/index.js:321:12)
  at next (/root/example-api/node_modules/express/lib/router/index.js:261:10)
  at logger (/root/example-api/node_modules/morgan/index.js:136:5)
  at Layer.handle [as handle_request] (/root/example-api/node_modules/express/lib/router/layer.js:82:5)
  at trim_prefix (/root/example-api/node_modules/express/lib/router/index.js:302:13)
  at /root/example-api/node_modules/express/lib/router/index.js:270:7
  at Function.proto.process_params (/root/example-api/node_modules/express/lib/router/index.js:321:12)
  at next (/root/example-api/node_modules/express/lib/router/index.js:261:10)
  at middleware (/root/example-api/node_modules/connect-assets/index.js:43:7)
  at Layer.handle [as handle_request] (/root/example-api/node_modules/express/lib/router/layer.js:82:5)
  at trim_prefix (/root/example-api/node_modules/express/lib/router/index.js:302:13)
  at /root/example-api/node_modules/express/lib/router/index.js:270:7
  at Function.proto.process_params (/root/example-api/node_modules/express/lib/router/index.js:321:12)
  at next (/root/example-api/node_modules/express/lib/router/index.js:261:10)
  at compression (/root/example-api/node_modules/compression/index.js:212:5)
  at Layer.handle [as handle_request] (/root/example-api/node_modules/express/lib/router/layer.js:82:5)
  at trim_prefix (/root/example-api/node_modules/express/lib/router/index.js:302:13)
  at /root/example-api/node_modules/express/lib/router/index.js:270:7
  at Function.proto.process_params (/root/example-api/node_modules/express/lib/router/index.js:321:12)
  at next (/root/example-api/node_modules/express/lib/router/index.js:261:10)
  at expressInit (/root/example-api/node_modules/express/lib/middleware/init.js:23:5)
  at Layer.handle [as handle_request] (/root/example-api/node_modules/express/lib/router/layer.js:82:5)
  at trim_prefix (/root/example-api/node_modules/express/lib/router/index.js:302:13)
  at /root/example-api/node_modules/express/lib/router/index.js:270:7
  at Function.proto.process_params (/root/example-api/node_modules/express/lib/router/index.js:321:12)
  at next (/root/example-api/node_modules/express/lib/router/index.js:261:10)
  at query (/root/example-api/node_modules/express/lib/middleware/query.js:28:5)
  at Layer.handle [as handle_request] (/root/example-api/node_modules/express/lib/router/layer.js:82:5)
  at trim_prefix (/root/example-api/node_modules/express/lib/router/index.js:302:13)
  at /root/example-api/node_modules/express/lib/router/index.js:270:7
  at Function.proto.process_params (/root/example-api/node_modules/express/lib/router/index.js:321:12)
  at next (/root/example-api/node_modules/express/lib/router/index.js:261:10)
  at Function.proto.handle (/root/example-api/node_modules/express/lib/router/index.js:166:3)
  at EventEmitter.app.handle (/root/example-api/node_modules/express/lib/application.js:170:10)
  at Server.app (/root/example-api/node_modules/express/lib/express.js:28:9)
  at Server.EventEmitter.emit (events.js:98:17)
  at HTTPParser.parser.onIncoming (http.js:2108:12)
  at HTTPParser.parserOnHeadersComplete [as onHeadersComplete] (http.js:121:23)
  at Socket.socket.ondata (http.js:1966:22)
  at TCP.onread (net.js:525:27)

POST /oauth/signin 403 22.926 ms - -

including phonegap.js or cordova.js in the example file

the current example file is including phonegap.js lib, which fits perfectly the tutorial mentioned in the README file.
however, i'm using cordova, and i was trying to run the example for few times without a success because it includes phonegap.js instead of cordova.js.

i would suggest adding a commented line above the inluding line, something like:

<!--
if you are using Apache Cordova instead of Adobe Phonegap, please comment the next line, and uncomment the one after it.
-->
<script type="text/javascript" src="phonegap.js"></script>
<!--<script type="text/javascript" src="cordova.js"></script>-->

WebView localhost errors with latest Phonegap (3.3)

01-29 22:18:59.466 8420-8420/com.winter.domain D/CordovaLog﹕ file:///android_asset/www/cordova.js: Line 1034 : processMessage failed: Message: S11 InAppBrowser1735723858 {"type":"loadstart","url":"http:\/\/localhost\/#oauthio=%7B%22status%22%3A%22error%22%2C%22message%22%3A%22Origin%20%5C%22http%3A%2F%2Flocalhost%5C%22%20does%20not%20match%20any%20registered%20domain%2Furl%20on%20domain.com%3A6284%22%2C%22state%22%3A%223k-usBTWsBdTNI1hCR5sq1ZqVSc%22%2C%22provider%22%3A%22facebook%22%7D"} 01-29 22:18:59.466 8420-8420/com.winter.domain I/chromium﹕ [INFO:CONSOLE(1034)] "processMessage failed: Message: S11 InAppBrowser1735723858 {"type":"loadstart","url":"http:\/\/localhost\/#oauthio=%7B%22status%22%3A%22error%22%2C%22message%22%3A%22Origin%20%5C%22http%3A%2F%2Flocalhost%5C%22%20does%20not%20match%20any%20registered%20domain%2Furl%20on%20domain.com%3A6284%22%2C%22state%22%3A%223k-usBTWsBdTNI1hCR5sq1ZqVSc%22%2C%22provider%22%3A%22facebook%22%7D"}", source: file:///android_asset/www/cordova.js (1034) 01-29 22:18:59.466 8420-8420/com.winter.domain D/CordovaLog﹕ file:///android_asset/www/cordova.js: Line 1035 : processMessage failed: Error: TypeError: Cannot call method 'get' of undefined 01-29 22:18:59.466 8420-8420/com.winter.domain I/chromium﹕ [INFO:CONSOLE(1035)] "processMessage failed: Error: TypeError: Cannot call method 'get' of undefined", source: file:///android_asset/www/cordova.js (1035) 01-29 22:18:59.466 8420-8420/com.winter.domain D/CordovaLog﹕ file:///android_asset/www/cordova.js: Line 1036 : processMessage failed: Stack: TypeError: Cannot call method 'get' of undefined

It immediately closes the InAppBrowser when calling popup and gives the following errors. I've changed the URL in the config as i'm using oauthd on my server. There works fine with the Try It button. Acces orgins are * in my config.xml.

result object

Is there some reason we can't call Oauth.result or OAuth.getResult to get the last result object?

Could not connect to the server.

Hello. I try to use this oAuth lib but i have a problem:

"webView:didFailLoadWithError - -1004: Could not connect to the server."

Can i help me?

I'm using in the same project oAuth plugin and the Facebook plugin (oficial plugin).

Phonegap Build instructions off/ambiguous/missing.

I am trying to install oauth via phongap build (build.phonegap.com). I've included the plugin and inappbrowser via:

<gap:plugin name="org.apache.cordova.inappbrowser" version="0.5.2" />
<gap:plugin name="com.oauthio.plugins.oauthio" version="0.2.4" />

However, when checking for variable OAuth on the page, I find it is always undefined (this is in the app, not a browser). Some plugins require including a .js file on the index page. The instructions made it sound like that was unnecessary for this one. However, when I did try to include oauth.js, it works up until I click sign in (using facebook), then it gives me a cannot connect error for http://localhost/[some tokens and variables]

clearCache or clear token

According the documentation of the Javascript API reference, there should be a function clearCache on the OAuth object.
But by inspecting the OAuth.js I couldn't find such a function. Is there any way to clear a token?

"The popup was closed" error message

I updated to 0.2.4, which also updated the InAppBrowser to 0.5.1. Now, when I use the popup login, I get the result object, but I am also getting the error string back that says "The popup was closed". The login seems successful, so I'm not sure why I'm receiving the error message. Any guidance on why that might be?

Edit: Sorry forgot to say that this is running on iOS 7.1.2.

Invalid format state:invalid or expired Error

We are using oauth plugin in our application for login.I send a login request to google plus using valid credentials.Before this process is completed a second request is triggered by tapping on the signin button again,the following error is thrown.

Error code in iPad console :2014-05-08 16:25:30.116 rpad_plos[2270:907] webView:didFailLoadWithError - -999: The operation couldn’t be completed. (NSU RLErrorDomain error -999)

response object not being parsed as json

When I use the api, I'm getting the json responses back as text and they aren't getting automatically converted to objects.

If I do this explicitly, it works:

authorizationResult.get(url, {dataType: "json"}).done(function(response) {

Is this a problem with the provider? I tried a few things to make this work including setting up the provider request object with a format of json.

popups not shown..

Can't get the example to work.. Nothing happens when i click the buttons.

Authentication!!

Hello, do i have to do OAuth.popup() every time i want to post a status update to twitter?.Is there a method or function i can use to post status updates without having to authenticate each time i want to post an update?.Thanks

Popup Error in Cordova 3.5.0-0.2.7

I have an Authio app that can connect to facebook and twitter successfully from the developer dashboard.

<access origin="*" /> appears in my config.xml inside the <widget> root node.

My project is Angular-based and I have these urls whitelisted with $sceDelegateProvider.resourceUrlWhitelist():

            'https://oauth.io/**',
            'https://graph.facebook.com/**',
            'https://api.twitter.com/**'

My auth function calls OAuth.initialize() with my key and the next line is OAuth.popup('facebook').

When run on Android, the popup just opens and closes quickly. On an iPhone, I get this error in the console:

webView:didFailLoadWithError - -1004: Could not connect to the server.

Dependency on jQuery just for $.ajax

Hi guys,

I recently had to work around an issue related to this plugin's dependency on jQuery. You're only using the $.ajax portion of it in OAuth.http, so you're mandating that your users take on a pretty heavy dependency for something pretty minimal and non-integral to your use case. Fortunately, this is easily redeemed.

I used xhr-ajax to implement my workaround, and it appears to work perfectly. I'd submit a pull request, but I don't have any idea about your preferred means of bundling dependencies. Hope you can manage to find a solution yourself, but let me know if I can be of assistance.

Cheers,
Eevert

InvalidHeaders

I implemented a login dialog for my phonegap app but when I click the button that triggers the Oauth.popup the following error appears:
Cannot find hostname in file:/// from static
code: InvalidHeader
message: Cannot find hostname in file:/// from static
It works perfectly in the browser and in Android but I can't get it working with ios

[Question] Ionic framework compatibility?

Hi,
I'm using the ionic framework in order to build a single page application. However, I can't seem to use this library with my project. There's a discussion thread with users that have the same issue: http://forum.ionicframework.com/t/oauth-io-plugin/3542

I've added the cordova inAppBrowser plugin. The popup works in the browser, however, it doesn't work when I deploy it via cordova. The popup isn't opened and the callback isn't called.

I've installed the inappbrowser plugin as seen in the config.xml:

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.ionicframework.starter" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>Payback</name>
    <description>
        The place where you get paidback.
    </description>
    <author email="hi@payback" href="http://example.com/payback">
      Payback Team
    </author>
    <content src="index.html" />
    <access origin="*" />
    <preference name="fullscreen" value="true" />
    <preference name="webviewbounce" value="false" />
    <preference name="UIWebViewBounce" value="false" />
    <preference name="DisallowOverscroll" value="true" />

    <!-- Don't store local date in an iCloud backup. Turn this to "cloud" to enable storage 
         to be sent to iCloud. Note: enabling this could result in Apple rejecting your app.
    -->
    <preference name="BackupWebStorage" value="none" />

    <gap:plugin name="org.apache.cordova.inappbrowser" />
    <feature name="InAppBrowser">
        <param name="android-package" value="org.apache.cordova.inappbrowser.InAppBrowser" />
    </feature>
    <feature name="InAppBrowser">
        <param name="ios-package" value="CDVInAppBrowser" />
    </feature>
</widget>

I'm a bit lost regarding this issue. Any thoughts?

Auth pop-up look-and-feel

I've asked a question on SO about changing the style of auth pop-up: http://stackoverflow.com/questions/26150505/phonegap-oauth-io-internal-browser-look-and-feel?noredirect=1#comment41026544_26150505

And I've got a comment mentioning "{authorize: { display: 'touch'}}" option of creating pop-up. But the commenter said that it's available not for all providers. I tried it with Twitter, but nothing seems changed.

So, is it really possible to manage look-and-feel of auth pop-up with Twitter provider? Default style is really bad (I mean navigation bar of the browser in the pop-up).

Added plugin to Steroids/AppGyver => OAuth.popup problem

Hi,

I added the plugin to an appgyver/steroids application

When I do a Oauth.getVersion() it returns me the version correctly

Then I do a Oauth.initialize('') with the facebook key
But when i call the Oauth.popup('facebook' function I got a : "undefined is not a function"
(in the interface I seen a very fast popup opening and closing blink)

I tried for several days to google and find a reason, I have no idea what's happening

Thanks for helping

Doesn't work in Windows 8.1 app?

Great plugin! However, it doesn't work in the Ripple emulator, so I tried as a Windows 8.1 app. It doesn't work either. I just get a blank page when I click "Connect to Twitter" in the example app.
All works fine in an Android app on my device...

customize ios toolbar

The ios toolbar is very ios 6

it would be nice to be able to at least change the color (at least remove the gradient) and maybe even change the text color of the back button.

Issue with Phonegap + OAuth + FitBit

Hello,
I am using the following code in my phonegap application:
`OAuth.initialize('octbeoSTEWly-ZoIYj9CIuxThEo');

            var promise = OAuth.popup('fitbit', { cache: true });
            promise.done(function (result) { 
                //////////console.log(result);
                console.log(result);

            });`

This code causes a popup to login/allow fitbit - then when it closes i get an alert on screen with a load of text,
screenshot_2015-04-08-12-47-56
and the following output in the chrome://inspect console.
screen shot 2015-04-08 at 12 48 03

I am running the app on a nexus 4 on android lollipop, built by phonegap build.

Ionic and cordova "OAuth is not defined"

npm install -g cordova ionic
ionic start myApp tabs
cordova plugin add https://github.com/oauth-io/oauth-phonegap
ionic serve

All I seem to ever get is "OAuth is not defined". Thoughts on how I can fix this?

Twitter Post Not Working

Hi,

I am trying to send a status update to twitter using the oauth-phonegap plugin, but it is failing to send. The authentication step is successful but when it tries to do the post I receive a 400 error saying that there is an invalid origin or header.

I have replicated the error using the Example solution, with the following index.html:

    <script type="text/javascript">
        $(document).on('deviceready', function() {
            OAuth.initialize("nQ5IntIg0oMEWtYkDOFEtPWsdL8");

            $('#tw-connect').on('click', function() {
                $('#result').html("");
                OAuth.popup("twitter", function(e,r) {
                    if (e)
                        $('#result').html('error: ' + e.message);
                    else
                            r.post({
                                     url: '/1.1/statuses/update.json',
                                     data: { status: $scope.shareMessage }
                                     }).done(function(data) {
                                             $('#result').html("Posted");
                                             });
                });
            });
        });
    </script>

Please could you let me know what I am doing wrong?

Thanks

Broken in phonegap and cordova

Tried exactly as in the readme, building fails:

Error: Expected Fetched plugin to have ID "org.apache.cordova.core.inappbrowser" but got "org.apache.cordova.inappbrowser".

Doesn't detect dependency...

I am having a lot of trouble getting this plugin to work. I created a clean slate phonegap project using

phonegap create cleanslate then I
cd cleanslate and
phonegap local plugin add https://github.com/oauth-io/oauth-phonegap which gives me an error

[phonegap] adding the plugin: https://github.com/oauth-io/oauth-phonegap
   [error] ENOENT, no such file or directory '/home/tvle83/phonegap/cleanslate/plugins/org.apache.cordova.inappbrowser/www/inappbrowser.js'

I look in that directory and there is a file there, but it's InAppBrowser.js rather than inappbrowser.js

How do I have it look for the all lowercase version?

Error uninstalling plugin

Got the following error trying to uninstall

$ cordova plugin remove com.phonegap.plugins.oauthio
Uninstalling com.phonegap.plugins.oauthio from ios
Error during processing of action! Attempting to revert...
Error: Uh oh!
"/Users/catrapture/dev/projects/phonegap/green-streak-ui/platforms/ios/.staging/www/oauth.js" not found!
at Object.module.exports.resolveSrcPath (/usr/local/lib/node_modules/cordova/node_modules/plugman/src/platforms/common.js:10:46)
at Object.module.exports.removeFile (/usr/local/lib/node_modules/cordova/node_modules/plugman/src/platforms/common.js:35:35)
at module.exports.asset.uninstall (/usr/local/lib/node_modules/cordova/node_modules/plugman/src/platforms/common.js:84:28)
at Object.ActionStack.process (/usr/local/lib/node_modules/cordova/node_modules/plugman/src/util/action-stack.js:46:25)
at handleUninstall (/usr/local/lib/node_modules/cordova/node_modules/plugman/src/uninstall.js:185:20)
at /usr/local/lib/node_modules/cordova/node_modules/plugman/src/uninstall.js:134:16
at _fulfilled (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:798:54)
at self.promiseDispatch.done (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:827:30)
at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:760:13)
at /usr/local/lib/node_modules/cordova/node_modules/q/q.js:821:14

How to use this with oauth.io?

How do I use this with oauth.io? My controller has this in it:

OAuth.initialize('longstring')
OAuth.popup( 'google', {
  cache: true })
.done(function(result) {...

I can auth with Google, but that information isn't sent to my remote server.

Installing InAppBrowser dev version

When installing Oauth Phonegap as it is recommended, here is the logs:

$ cordova plugin add https://github.com/oauth-io/oauth-phonegap
Fetching plugin "https://github.com/oauth-io/oauth-phonegap" via git clone
Installing "com.phonegap.plugins.oauthio" for android
Fetching plugin "https://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser.git" via git clone
Installing "org.apache.cordova.inappbrowser" for android

$  cordova plugin ls
com.phonegap.plugins.oauthio 0.2.1 "OAuth.io"
org.apache.cordova.inappbrowser 0.5.1-dev "InAppBrowser"

You see that the InAppBrowser version that was installed is the dev version of the InAppBrowser, which happens to do nothing on my computer and cellphone (and emulator).

When I first install InAppBrowser then OAuth, it works.

$ cordova plugin add org.apache.cordova.inappbrowser
Fetching plugin "org.apache.cordova.inappbrowser" via plugin registry
Installing "org.apache.cordova.inappbrowser" for android
$ cordova plugin add https://github.com/oauth-io/oauth-phonegap
Fetching plugin "https://github.com/oauth-io/oauth-phonegap" via git clone
Installing "com.phonegap.plugins.oauthio" for android
$ cordova plugin ls
com.phonegap.plugins.oauthio 0.2.1 "OAuth.io"
org.apache.cordova.inappbrowser 0.5.0 "InAppBrowser"

I do not know if this is a problem of cordova plugin manager or of OAuth but it would be nice if it would be in the docs.

OAuth.popup does not seem to support the state: option

When working with Server Side flow of OAuth.io with Node.js the Cordova.popup doesnt seem to handle the passing of the state property that was created from the server, it looks like the code creates it own state: property even if one is passed into the app. ? Is this correct

Thanks

Matt

SHA-1

Isn't this deprecated? Shouldn't you be using SHA-2 or SHA-3?

Can't find variable:OAuth

the oauth-phonegap isn't working for me. I'm trying it on iOS. Xcode 5.02, Phonegap 3.2.0

safari console errors "Can't find variable:OAuth".
and
"missing } after property list" in line 82 in oauth.js

I don't know if I did something wrong, i tried it over and over again.

Can't find variable: OAuth

No matter what I try I get this error while trying the phonegap plugin. When I use the js version, I get an error saying Cannot find hostname in file:/// from static
It was working before. I can't figure what could have caused this.

Insertion of jQuery without my knowledge

Hello,

When OAuth does not find jQuery, it tries to be clever and inserts jQuery. The problem is that I use Zepto so I would prefer if it would check for $, fails if it does not find window.$ and fails hard instead of doing the magic of inserting a script tag with code.jquery.com/jquery-2.11.1.js . Moreover, since it is on mobile, we cannot rely on the network being there when the user opens the application.

What do you think ?

OAuth is not defined

Hi,

I am having an error where OAuth seems to be undefined.

Steps to reproduce:

phonegap create testApp
phonegap plugin add https://github.com/oauth-io/oauth-phonegap

This step says the plugin is installed successfully. However:

phonegap plugin list
[phonegap] no plugins installed

I might be missing some steps? 3.5.0-0.20.4 is my phonegap version

Unable to change user

(tested with facebook & google on iOS)

Once a user successfully logs in the first time, there's no way to switch to another account. Typically you'd expect to be able to go to the provider's site and change users there, then the affect would carry through but it doesn't in this case, as it seems the system browser / phonegap / child window are all isolated. Is there any way we can clear the cache on the child window? I'd like to do this on my applications logout, so the user will be able to switch accounts.

Thanks!!

Missing required parameter: scope

When I try using OAuth.popup('google') I get the attached screenshot:

Error: invalid_request
Missing required parameter: scope
Request Details
response_type=code
redirect_uri=https://oauth.io/auth
state=athxRYu1cR1BrFIxtJmSP8GifWA

Is this project being actively maintained? I see someone reported a similar issue on the php client:
oauth-io/sdk-php#19

ios simulator screen shot jun 8 2015 6 49 31 pm

Logout API for Cordova user

It would be nice if we can logging out user from specific provider via the API. For now I just using Cordova Cookies plugin with 'window.cookies.clear()' to clear all inappbrowser data. Then It will automatically logout.

Moreover, If user be able to config the inappbrowser options of the popup function. For now I have to change the code in oauth.js mobile for adding the back button in inappbrowser.

Approximately Line: 227 : wnd = window.open(url, "_blank", 'location=no,toolbar=yes,closebuttoncaption=Back,hidden=yes,presentationstyle=formsheet,toolbarposition=top');

Or even add some event listener to the wnd.

I would love to see OAuth.io include such of features in the future relase.

Best Regards,
Popeye

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.