Cordova plugin for performing OAuth login flows.

Usage no npm install needed!

<script type="module">
  import cordovaPluginOauth from '';



This plugin provides a mechanism for showing an OAuth flow in a secured system-provided browser view and receiving the result via a Message event.

On iOS, this uses ASWebAuthenticationSession (iOS >=12), SFAuthenticationSession (iOS 11), SFSafariViewController (iOS >=8, <=10), falling back to Safari.

On Android, this uses Custom Tabs in the user's preferred web application, falling back to their browser.

Note: This plugin might conflict with the Cordova In-App Browser plugin!


cordova plugin add cordova-plugin-oauth

Supported Platforms

  • iOS (cordova-ios >= 5.0.0)
  • Android (cordova-android >= 8.0.0)


  1. Trigger the plugin by opening the OAuth login page in a new window, with a window name that includes "oauth:":

    var endpoint = '';, 'oauth:google', '');

    By default, the plugin registers the app ID as a scheme to be used as the OAuth callback URL, and expects a host of oauth_callback (i.e., if your app's ID is, your OAuth redirect URL should be

  2. The plugin will open the OAuth login page in a new browser window.

  3. When the OAuth process is complete and it redirects to your app scheme, the plugin will send a message to the Cordova app.

    The message begins with oauth:: and is followed by a JSON object containing all of the key/value pairs from the OAuth redirect query string.

    // Called from a callback URL like
    // it would be received in JavaScript like this:
    window.addEventListener('message', function(event) {
      if (^oauth::/)) {
        var data = JSON.parse(;
        // Use data.code

    The advantage of this implementation is that it can be made to work with Universal Links and App Links so that the same flow can be used in both mobile apps and web.


Contributions of bug reports, feature requests, and pull requests are greatly appreciated!

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.


Released under the Apache 2.0 Licence.
Copyright © 2019 Ayogo Health Inc.