Coder Social home page Coder Social logo

nativescript-oauth2's Introduction

OAuth 2 Plugin for NativeScript

Build Status NPM version Downloads Twitter Follow

Library for interacting with OAuth 2.0 in NativeScript applications that provides simplified direct client access with a OAuth providers that support the OAuth 2.0 protocol such as Microsoft, Facebook, and Google, but not limited to any login providers, and even allows you to plug in your own. This library doesn't use any native libraries and relies only on what comes in the box - making it really lightweight.

NOTE: This is the new version of the old nativescript-oauth plugin

NOTE: For NativeScript 7 support, use version 3+ of this plugin. For versions of NativeScript that are less than 7, use versions less than 3 of this plugin.

NativeScript OAuth 2


Tested against Microsoft, Facebook, and Google providers. More providers are coming soon. Thanks to all those who contributed providers to the old plugin - please do the same for this one.

Introduction

Some providers are OpenId certified (Google, Microsoft) so they are a bit more secure in that they don't have to store the client secret on the client (which can always be pwned by folks that are savvy enough to get into your app). Google doesn't allow client secrets to be passed and requires an out-of-app browser to be used for auth. This plugin supports this method for any providers that require it, but there are a few extra configuration steps that have to be performed to get this working, more on that below.

Facebook doesn't support OpenId and works with the in-app WebView implementation of the auth process. So while this requires less configuration, there is an slight security risk of keeping your client secret in the app. If you have strict security requirements, you have to implement Facebook login by using your backend as a proxy between this plugin and Facebook auth servers.

Prerequisites

Office 365 / Microsoft

For logging in with your Office 365 account, you should have an Office 365 Account admin account. If you don't have one yet, you can get a free trial here.

Keep an eye out on my YouTube channel for a video on how to set up Facebook with with plugin.

Register your mobile app here.

Microsoft login will work either with the in-app webview method, in which case your redirectUri config property can be set to urn:ietf:wg:oauth:2.0:oob. Or it can use the more secure method that doesn't require a client secret, but it will need to have a custom URL scheme registered (see below).

Facebook account

For logging in with your Facebook account, you should have a Facebook developer account. If you don't have one yet, you can get one here.

Keep an eye out on my YouTube channel for a video on how to set up Facebook with with plugin.

Register your mobile app by following the wizard under "My Apps" -> "Add a new app".

  1. Go to https://developers.facebook.com/apps and create a new app
  2. If you see the Product Setup page, select Facebook login
  3. Make sure to turn ON the option "Embedded Browser OAuth Login"
  4. Click Save
  5. Copy the App ID and the App Secret from the Dashboard page to bootstrap your app. These will be the ClientID and ClientSecret respectively.

Google account

For logging in with your Google account, you should have a Google developer account. If you don't have one yet, you can get one here.

Keep an eye out on my YouTube channel for a video on how to set up Google with this plugin.

Register your mobile app by following the wizard in the Developer Console. (more info coming soon)

Google login will only work with the out-of-app browser. You must register a custom URL scheme for your app (see below).

LinkedIn Account

For logging in with your LinkedIn account, you should have a LinkedIn developer account. If you don't have one yet, you can get one here.

  1. Click on My Apps and login with your LinkedIn credentials or click on Join Now to create a new account.
  2. Once logged in click on Create Application.
  3. Fill out all fields with the app's information and Click submit.
  4. If everything goes well you should get your app's authentication keys which consists of a client id and a client secret.
  5. In this page, make sure to add an Authorized Redirect URL. (This can be any url starting with http:// or https://).
  6. Copy the Authentication Keys and the Authorized Redirect URL.

IdentityServer Account

For logging in with IdentityServer you can make use of the demo server or create your own. You can get more information on how to start your own IdentityServer here.

The default IdentityServer provider is configured to use the demo server with client id: native.code grant type: authorization code with PKCE and client credentials.

login with bob/bob, alice/alice or choose external login with Google or Azure AD.

Setup

Add TypeScript to your NativeScript project if you don't already have it added. While this is not a requirement, it's highly recommended. If you want to watch a video on how to convert your existing JavaScript based NativeScript app to TypeScript, watch it here.

From the command prompt go to your app's root folder and execute:

npm install nativescript-oauth2 --save

Usage

If you want a quickstart, you can start with one of two demo apps:

Bootstrapping

When your app starts up, you'll have to register one or more auth providers to use with the nativescript-oauth2 plugin. You'll use the code below to register the providers.

NativeScript Core

If you are using NativeScript Core, open app.ts and add the following registration code before application.start();

NativeScript with Angular

If you are using Angular AND you are NOT using <page-router-outlet, you'll need to enable frames in order for the plugin to open up a new native page with a login screen. To do that open your main.ts file. You will need to explicitly use frames, so make sure to pass an options object to platformNativeScriptDynamic with the createFrameOnBootstrap flag set to true, like this.

// main.ts
platformNativeScriptDynamic({ createFrameOnBootstrap: true }).bootstrapModule(
  AppModule
);

You don't need to do this if you already have <page-router-outlet> in your component.

then add add the registration code below somewhere before you call login, most likely in your Auth service, as in the demo-angular project.

NativeScript-Vue

If you are using NativeScript-Vue, then you'll have to add this registration code somewhere when your app bootstraps. A Vue demo app is included with the GitHub repo.

// This is the provider registration example code

import { configureTnsOAuth } from "nativescript-oauth2";

import {
  TnsOaProvider,
  TnsOaProviderOptionsFacebook,
  TnsOaProviderFacebook,
  TnsOaProviderOptionsGoogle,
  TnsOaProviderGoogle,
  TnsOaProviderOptionsMicrosoft,
  TnsOaProviderMicrosoft,
} from "nativescript-oauth2/providers";

function configureOAuthProviderGoogle(): TnsOaProvider {
  const googleProviderOptions: TnsOaProviderOptionsGoogle = {
    openIdSupport: "oid-full",
    clientId:
      "932931520457-buv2dnhgo7jjjjv5fckqltn367psbrlb.apps.googleusercontent.com",
    redirectUri:
      "com.googleusercontent.apps.932931520457-buv2dnhgo7jjjjv5fckqltn367psbrlb:/auth",
    urlScheme:
      "com.googleusercontent.apps.932931520457-buv2dnhgo7jjjjv5fckqltn367psbrlb",
    scopes: ["email"],
  };
  const googleProvider = new TnsOaProviderGoogle(googleProviderOptions);
  return googleProvider;
}

function configureOAuthProviderFacebook(): TnsOaProvider {
  const facebookProviderOptions: TnsOaProviderOptionsFacebook = {
    openIdSupport: "oid-none",
    clientId: "691208554415641",
    clientSecret: "d8725ac416fa1bb1917ccffd1670e3c7",
    redirectUri: "https://www.facebook.com/connect/login_success.html",
    scopes: ["email"],
  };
  const facebookProvider = new TnsOaProviderFacebook(facebookProviderOptions);
  return facebookProvider;
}

configureTnsOAuth([
  configureOAuthProviderGoogle(),
  configureOAuthProviderFacebook(),
]);

The plugin comes with helpful interfaces that you can implement for the providers as well as the options that can be passed into each provider's constructor. You don't have to use these interfaces, but they are helpful guides. The code above shows these interfaces.

The last call to configureTnsOAuth() takes an array of providers and registers them as available for use.

Logging in

When you're ready to login, or as a response to a tap event on a login button, you can create a new instance of the TnsOAuthClient and call loginWithCompletion() on the instance, passing in the provider you want to login with. The provider is of the type TnsOaProviderType, or it can be a string 'google', 'facebook', 'microsoft', etc.

By default, this plugin enables PKCE (Proof Key for Code Exchange) since version 2.0.0. If you want to disable it, pass in false as the second argument of the TnsOAuthClient constructor.

import { TnsOAuthClient, ITnsOAuthTokenResult } from "nativescript-oauth2";

const client = new TnsOAuthClient(providerType);

client.loginWithCompletion((tokenResult: ITnsOAuthTokenResult, error) => {
  if (error) {
    console.error("back to main page with error: ");
    console.error(error);
  } else {
    console.log("back to main page with access token: ");
    console.log(tokenResult);
  }
});

After login is done, the completion handler will be called with the results.

Refreshing the Access Token

Once you have logged in, you can call refreshTokenWithCompletion() on your TnsOAuthClient instance to attempt to refresh your access token. In order to do this, the following criteria must be met:

  • The scope offline_access was requested when you logged in.
  • The TnsOAuthClient must have the token result from your previous login. If you have the original instance you used to log in, it will already be on the object. If you do not have the original instance of TnsOAuthClient which you used to log in, such as if the app was restarted, then assign the client's tokenResult property to your token.

If that criteria is met, then you can refresh the token like so:

import { TnsOAuthClient, ITnsOAuthTokenResult } from "nativescript-oauth2";

...

client.refreshTokenWithCompletion((tokenResult: ITnsOAuthTokenResult, error) => {
  if (error) {
    console.error("Unable to refresh token with error: ");
    console.error(error);
  } else {
    console.log("Successfully refreshed access token: ");
    console.log(tokenResult);
  }
});

Creating a custom provider

If you don't see an auth provider that you need, you can just implement your own - see the demo-custom-provider project in the GitHub repo for an example on how to do this.

You need to implement two interfaces: provider options that suits your provider (more below), and TnsOaProvider for the provider endpoint details.

Provider Options

Implement your provider's options by extending the TnsOaUnsafeProviderOptions interface if your provider is not Open Id compliant, or the TnsOaOpenIdProviderOptions interface if your provider is Open Id compliant.

Note: the interface is named with the word 'unsafe' in the name because non-open id compliant providers (like Facebook) usually make you use a client secret to send to the provider in exchange for the token. Storing the secret somewhere other than the client app is recommended (like a proxy), but most people don't do this and just store the secret with the app - thus unsafe.

//Provider options example

export interface TnsOaMyCustomProviderOptions
  extends TnsOaUnsafeProviderOptions {}

TnsOaProvider

Then you can create your provider class by implementing the TnsOaProvider interface:

//Provider implementation example

export class TnsOaProviderMyCustomProvider implements TnsOaProvider {
  public options: TnsOaProviderOptions;
  public openIdSupport: OpenIdSupportNone = "oid-none";
  public providerType = "myCustomProvider";
  public authority = "https://www.facebook.com/v3.1/dialog";
  public tokenEndpointBase = "https://graph.facebook.com";
  public authorizeEndpoint = "/oauth";
  public tokenEndpoint = "/v3.1/oauth/access_token";
  public cookieDomains = ["facebook.com"];

  constructor(options: TnsOaMyCustomProviderOptions) {
    this.options = options;
  }

  public parseTokenResult(jsonData): ITnsOAuthTokenResult {
    return jsonData;
  }
}

Finally, you'll use your provider when you register it with the app.

// app.ts

import * as application from "tns-core-modules/application";
import { configureOAuthProviders } from "./auth-service";
configureOAuthProviders();
application.run({ moduleName: "app-root" });
// auth-service.ts

export function configureOAuthProviders() {
  const myCustomProvider = configureOAuthProviderMyCustomProvider();
  configureTnsOAuth([myCustomProvider]);
}
function configureOAuthProviderMyCustomProvider(): TnsOaProvider {
  const facebookProviderOptions: TnsOaMyCustomProviderOptions = {
    openIdSupport: "oid-none",
    clientId: "<your client/app id>",
    clientSecret: "<your client secret>",
    redirectUri: "<redirect Uri>",
    scopes: ["email"],
    customQueryParams: {
      foo: "bar",
    },
  };
  const facebookProvider = new TnsOaProviderMyCustomProvider(
    facebookProviderOptions
  );
  return facebookProvider;
}

Custom URL Scheme

If you are using an OpenId certified provider and need to use an out-of-app browser to authenticate, then you must register a custom URL scheme with your app. This is easy to do with NativeScript. The first step is to register your custom scheme with your provider when you register your app.

Android

To register a custom URL scheme for Android, open your Android app resources, which are in this path: app/App_Resources/Android/src/main/AndroidManifest.xml. The AndroidManifest.xml file used to be right in the Android folder, but now it's been moved down a bit. It's still the same file though.

Find the <activity> section named com.tns.NativeScriptActivity and add the attribute android:launchMode="singleTask" (or singleTop). Then inside the activity add a new <intent-filter> section with your custom url scheme(s).

Here is an example of the entire <activity> section:

		<activity android:name="com.tns.NativeScriptActivity" android:launchMode="singleTask" android:label="@string/title_activity_kimera" android:configChanges="keyboardHidden|orientation|screenSize" android:theme="@style/LaunchScreenTheme">

			<meta-data android:name="SET_THEME_ON_LAUNCH" android:resource="@style/AppTheme" />

			<intent-filter>
				<action android:name="android.intent.action.MAIN" />
				<category android:name="android.intent.category.LAUNCHER" />
			</intent-filter>

			<intent-filter>
				<action android:name="android.intent.action.VIEW"/>
				<category android:name="android.intent.category.DEFAULT" />
				<category android:name="android.intent.category.BROWSABLE" />
				<!-- Custom URL Schemes -->
				<data android:scheme="com.googleusercontent.apps.932931520457-buv2dnhgo7jjjjv5fckqltn367psbrlb"/>
				<data android:scheme="msalf376fa87-64a9-89a1-8b56-e0d48fc08107"/>
			</intent-filter>

		</activity>

Notice in the config above, I've registered TWO custom URL schemes for my app - this is the <data> element with the path and scheme attributes.

iOS

To register a custom URL scheme for iOS, open your iOS app resources, which are in this path: app/App_Resources/iOS/Info.plist. In the key/value dictionary in this file, add a key for CFBundleURLTypes, if it's not already there. And add the value for that key as an array. The entire addition is listed here:

	<key>CFBundleURLTypes</key>
	<array>
		<dict>
			<key>CFBundleTypeRole</key>
			<string>Editor</string>
			<key>CFBundleURLName</key>
			<string>org.nativescript.testnsazmobaplugin</string>
			<key>CFBundleURLSchemes</key>
			<array>
				<string>msalf376fa87-64a9-49a1-8b57-e0d48fc08107</string>
				<string>fb691208554415647</string>
				<string>com.googleusercontent.apps.932931520457-buv2dnhgo7jjjjv5fckqltn367psbrlb</string>
			</array>
		</dict>
	</array>

Notice that for the key CFBundleURLSchemes, there are three string listed as custom URL schemes, all of them will open your app.

Contributing

  1. Follow the plugin authoring guidelines in the NativeScript docs.
  2. Use the Pull Request Template that can be found here to submit the PR.

Contributing Quick Steps

  1. Clone the repo: https://github.com/alexziskind1/nativescript-oauth2.git
  2. Open a terminal and navigate to /src folder
  3. Run npm run build, then run npm run plugin.tscwatch
  4. Open another terminal in the /src folder
  5. Run the Angular demo on iOS by executing the command npm run demo.ios-angular. For other demos on other platforms, see the different scripts available in the package.json file ion the src folder (package.json file)

nativescript-oauth2's People

Contributors

alexziskind1 avatar burgov avatar eddyverbruggen avatar ejlocop avatar elrashid avatar facetious avatar heyweswu avatar janwillemkeizer avatar joshdsommer avatar pauly93 avatar timoschlueter avatar vincentpalita-whoz 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nativescript-oauth2's Issues

Support Keycloak

Hi,

Thanks of this plugin and it reduce my work. I'd modify providers/provider.js to support keycloak, tested it work in ios only. Android it show blank page instead of login form (Seems SSL issue), after by pass SSL it still facing another issue which is webview no callback success status (another error which is session not exists). Need your advise how to make it work in android.

Below is the additional code of provider.js:

//add keycloak into provider.js
var TnsOaProviderKeycloak = (function () {
    function TnsOaProviderKeycloak(options,keycloakbaseurl,realm) {
        this.openIdSupport = "oid-none";
        this.providerType = "keycloak";
        this.authority = keycloakbaseurl;
        this.tokenEndpointBase = keycloakbaseurl;
        this.authorizeEndpoint = '/realms/'+realm+'/protocol/openid-connect/auth';
        this.tokenEndpoint = '/realms/'+realm+'/protocol/openid-connect/token';
        this.cookieDomains = [realm];
        this.options = options;
    }
    TnsOaProviderKeycloak.prototype.parseTokenResult = function (jsonData) {
        return jsonData;
    };
    return TnsOaProviderKeycloak;
}());
exports.TnsOaProviderKeycloak = TnsOaProviderKeycloak;

I'm not really understand how nativescript plugin system (how .ts convert to .js) work, and the plugin seems no distribute provider.ts (in fact, our project not use typescript). So I submit above code hope you can you merge into your project and benefit others keycloak user.

for usage, auth-service.js:

function configureOAuthProviderKeycloak() {
  var serverurl='https://<keycloakserver>/auth';
  var realm='keycloakrealm';
    var keycloakProviderOptions = {        
        openIdSupport: "oid-none",
        clientId: "keycloakclientid",
        clientSecret: "clientsecret",
        redirectUri: "redirecturl",        
        scopes: ["email"]
    };
    var keycloakProvider = new providers_1.TnsOaProviderKeycloak(keycloakProviderOptions,serverurl,realm);
    return keycloakProvider;
}

at landingpage, I use below:

var auth_service_1 = require("~/auth-service");
auth_service_1.configureOAuthProviders();
auth_service_1.tnsOauthLogin("keycloak");

Thanks
Ks

Sintax problem in vue-cli

Hi,

I have some problems with the sintax (this 2 lines) with the vue-cli:

Unexpected token, expected "{"

function configureOAuthProviderGoogle(): TnsOaProvider {
  const googleProviderOptions: TnsOaProviderOptionsGoogle = {

Thanks

Google Authentication not redirecting back to app

Make sure to check the demo app(s) for sample usage

Make sure to check the existing issues in this repository

If the demo apps cannot help and there is no issue for your problem, tell us about it

Please, ensure your title is less than 63 characters long and starts with a capital
letter.

Which platform(s) does your issue occur on?

Android

Please, provide the following version numbers that your issue occurs with:

tns version: 5.1.0
tns-core-modules: ~5.0.2,
tns-android: 5.0.0

Please, tell us how to recreate the issue in as much detail as possible.

I am using Google authentication through an Identity server.

provider:
import { TnsOaProvider, TnsOaProviderOptions, OpenIdSupportNone, TnsOaUnsafeProviderOptions, OpenIdSupportFull, TnsOaOpenIdProviderOptions } from "nativescript-oauth2/providers";
import { ITnsOAuthTokenResult } from "nativescript-oauth2";

export interface TnsOaMyCustomProviderOptions extends TnsOaOpenIdProviderOptions { }

export class TnsOaProviderMyCustomProvider implements TnsOaProvider {
public options: TnsOaProviderOptions;
public openIdSupport: OpenIdSupportFull = "oid-full";
public providerType = "provderName";
public authority = "identityserverUrl";
public tokenEndpointBase = "IdenityServerUrl";
public authorizeEndpoint = "/connect/authorize";
public tokenEndpoint = "/connect/token";
public cookieDomains = [""];
public clientSecret = "";
public clientId = "";
public redirectUri = "";

constructor(options: TnsOaMyCustomProviderOptions) {
    this.options = options;
}

public parseTokenResult(jsonData): ITnsOAuthTokenResult {
    return jsonData;
}

}

service:

import {
TnsOAuthClient,
configureTnsOAuth,
ITnsOAuthTokenResult
} from "nativescript-oauth2";
import {
TnsOaProvider, TnsOaProviderOptions, TnsOaOpenIdProviderOptions
} from "nativescript-oauth2/providers";
import { TnsOaMyCustomProviderOptions, TnsOaProviderMyCustomProvider } from "./nativescript-authentication-provider.service";

let client: TnsOAuthClient = null;

export function configureOAuthProviders() {
const myCustomProvider = configureOAuthProviderMyCustomProvider();
configureTnsOAuth([myCustomProvider]);
}

function configureOAuthProviderMyCustomProvider(): TnsOaProvider {
const facebookProviderOptions: TnsOaOpenIdProviderOptions = {
openIdSupport: "oid-full",
clientId:
"nativeapp",
redirectUri:
"com.googleusercontent.apps.932931520457-buv2dnhgo7jjjjv5fckqltn367psbrlb:/home",
urlScheme:
"com.googleusercontent.apps.932931520457-buv2dnhgo7jjjjv5fckqltn367psbrlb",
scopes: ["openid profile Panibus"]
};
const facebookProvider = new TnsOaProviderMyCustomProvider(facebookProviderOptions);
return facebookProvider;
}

export function tnsOauthLogin(providerType) {
client = new TnsOAuthClient(providerType);

client.loginWithCompletion((tokenResult: ITnsOAuthTokenResult, error) => {
if (error) {
console.error("back to main page with error: ");
console.error(error);
} else {
console.log("back to main page with access token: ");
console.log(tokenResult);
}
});
}

export function tnsOauthLogout() {
if (client) {
client.logout();
}
}

Android Manifest Intent Filter:

			<data android:path="/auth" android:scheme="com.googleusercontent.apps.932931520457-buv2dnhgo7jjjjv5fckqltn367psbrlb"/>
            <data android:path="/auth" android:scheme="msalf376fa87-64a9-89a1-8b56-e0d48fc08107"/>
        </intent-filter>

For the service I also tried :/home
For the Android Manifest I tried different combinations. To my understanding the 'android:path' is the route I want it to go to if successfull.

Is there any code involved?

There is no other code. We have an Identity server in place. Currently with the code above it opens our identity server url correctly in a different browser ( i chose chrome) and then I hit 'Google Login'.
When the emails come up I select mine from google. and it then hangs. Not being redirected to the app or identity server.

Any help is greatly appreciated.

Demo-vue fails on npm install

Which platform(s) does your issue occur on?

  • iOS
  • Device: iPhone 7 plus

Please, provide the following version numbers that your issue occurs with:

  • CLI: 5.4.0
  • Cross-platform modules: node_modules directory is empty
  • Runtime(s): tns-ios 5.2.0
  • Plugin(s):
    "dependencies": {
    "nativescript-vue": "2.0.2",
    "nativescript-oauth2": "file:../src",
    "tns-core-modules": "5.2.0"
    },
    "devDependencies": {
    "@babel/core": "^7.0.0",
    "@babel/preset-env": "^7.0.0",
    "babel-loader": "^8.0.2",
    "babel-traverse": "6.26.0",
    "babel-types": "6.26.0",
    "babylon": "6.18.0",
    "clean-webpack-plugin": "^0.1.19",
    "copy-webpack-plugin": "^4.5.2",
    "css-loader": "^1.0.0",
    "lazy": "1.0.11",
    "nativescript-dev-webpack": "next",
    "nativescript-vue-template-compiler": "^2.0.2",
    "nativescript-worker-loader": "~0.9.0",
    "node-sass": "^4.9.2",
    "sass-loader": "^7.1.0",
    "terser-webpack-plugin": "^1.1.0",
    "vue-loader": "^15.2.6",
    "webpack": "^4.16.4",
    "webpack-bundle-analyzer": "~2.13.1",
    "webpack-cli": "^3.1.0"
    }

Please, tell us how to recreate the issue in as much detail as possible.

$ git clone https://github.com/alexziskind1/nativescript-oauth2.git
$ cd nativescript-oauth2/demo-vue
$ npm install
WARN tar ENOENT: no such file or directory, open '/Users/marcelo/Documents/root/rings/nativescript-oauth2/demo-vue/node_modules/.staging/microevent.ts-899fbe76/package.json'
WARN tar ENOENT: no such file or directory, open '/Users/marcelo/Documents/root/rings/nativescript-oauth2/demo-vue/node_modules/.staging/microevent.ts-899fbe76/.travis.yml'
WARN tar ENOENT: no such file or directory, open '/Users/marcelo/Documents/root/rings/nativescript-oauth2/demo-vue/node_modules/.staging/microevent.ts-899fbe76/LICENSE'
WARN tar ENOENT: no such file or directory, open '/Users/marcelo/Documents/root/rings/nativescript-oauth2/demo-vue/node_modules/.staging/microevent.ts-899fbe76/README.md'
WARN tar ENOENT: no such file or directory, open '/Users/marcelo/Documents/root/rings/nativescript-oauth2/demo-vue/node_modules/.staging/microevent.ts-899fbe76/tsconfig.json'
WARN tar ENOENT: no such file or directory, open '/Users/marcelo/Documents/root/rings/nativescript-oauth2/demo-vue/node_modules/.staging/microevent.ts-899fbe76/tsconfig.test.json'
WARN tar ENOENT: no such file or directory, open '/Users/marcelo/Documents/root/rings/nativescript-oauth2/demo-vue/node_modules/.staging/microevent.ts-899fbe76/typings.json'
WARN tar ENOENT: no such file or directory, open '/Users/marcelo/Documents/root/rings/nativescript-oauth2/demo-vue/node_modules/.staging/microevent.ts-899fbe76/yarn.lock'
npm WARN [email protected] requires a peer of typescript@* but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] No repository field.

npm ERR! path /Users/marcelo/Documents/root/rings/nativescript-oauth2/demo-vue/node_modules/.staging/nativescript-oauth2-a74cb9fb/node_modules/ansi-regex
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename '/Users/marcelo/Documents/root/rings/nativescript-oauth2/demo-vue/node_modules/.staging/nativescript-oauth2-a74cb9fb/node_modules/ansi-regex' -> '/Users/marcelo/Documents/root/rings/nativescript-oauth2/demo-vue/node_modules/.staging/ansi-regex-dcbdd206'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

(then it freezes there)

Is there any code involved?

  • No - this is the clone of the repo

Thanks!!!

M

Bug: startTokenRefresh uses wrong token URL

Right now the token URL to refresh a token gets build via this.client.provider.authority + this.client.provider.tokenEndpoint (see here).

Though it should use this.client.provider.tokenEndpointBase as the base, or even better just use the function getAccessTokenUrl.

Because of this all refresh requests are invalid currently.

customDelegate

I am developing with IOS.

The plugin is working fine for me, but I have a custom delegate and there is not working when i use this plugin.

In my delegate I have other configurations to the application, for example configuration for login with twitter and here i put the code for the initialisation.

I can see that the plugin "oauth2" is creating a delegate.

My question is if someone know if its posible to work the plugin and my delegate configuration..

Thanks

Expose Webview to allow custom config/handlers

Hi, I see that you closed #33 citing that "Providing a custom UI goes against the Oauth2 spec", but there are other reasons that exposing the Webview would be very useful:

  • Set Android WebView settings:
    • webview.android.setWebChromeClient(new android.webkit.WebChromeClient());
    • android.getSettings().setBuiltInZoomControls(false);
    • android.getSettings().setUserAgentString('CUSTOM_UA_STRING');
  • Set custom loadStartedEvent and loadFinishedEvent handlers

Are there other ways to accomplish the tasks above without accessing the Webview?

Is createFrameOnBootstrap: true necessary?

Dear Alex,

In the docs is says that for Angular projects the flag createFrameOnBootstrap must be set to true

// main.ts platformNativeScriptDynamic({ createFrameOnBootstrap: true }).bootstrapModule( AppModule );

I tried it without setting this flag and it still works just the same (using Google authentication). So what gives? What goes wrong if I don't set this flag?
The problem with setting the flag to true is that I need to use page-router-outlet since I am in a code sharing Angular project and I need to reuse the routing code and I still need the "back" button of Android to work as expected with the navigation.
When you set the above flag to true AND use page-router-outlet at the same time you end up with undesirable behavior such as two action bars:

image

So if I can get away without this flag, it would be great.

Best wishes

Features - loginWithCompletion / Verify

Hello,

for the function loginWithCompletion is it important to get the response for some oauth like instagram e.g. to get the user data object.

And how can i check, on app start if is the user has registered the app like with a verification?

Thank you!

Microsoft loggin problem

  • CLI: 5.1.0

  • Cross-platform modules: Android 4.2.0(check the 'version' attribute in the
    node_modules/tns-core-modules/package.json file in your project)

  • Plugin(s): "@angular/animations": "5.2.0",
    "@angular/common": "5.2.0",
    "@angular/compiler": "5.2.0",
    "@angular/core": "5.2.0",
    "@angular/forms": "5.2.0",
    "@angular/http": "5.2.0",
    "@angular/platform-browser": "5.2.0",
    "@angular/platform-browser-dynamic": "5.2.0",
    "@angular/router": "5.2.0",
    "base-64": "^0.1.0",
    "nativescript-angular": "~5.2.0",
    "nativescript-bitmap-factory": "^1.7.1",
    "nativescript-checkbox": "^3.0.3",
    "nativescript-clipboard": "^1.1.7",
    "nativescript-exit": "^1.0.1",
    "nativescript-loading-indicator": "^2.4.0",
    "nativescript-oauth2": "^1.3.1",
    "nativescript-plugin-firebase": "^5.3.1",
    "nativescript-pro-ui": "~3.3.0",
    "nativescript-push-notifications": "^1.1.4",
    "nativescript-ripple": "^2.1.0",
    "nativescript-social-share": "github:moderateepheezy/nativescript-social-share#patch-1",
    "nativescript-sqlite": "^2.2.1",
    "nativescript-status-bar": "^1.1.1",
    "nativescript-theme-core": "~1.0.4",
    "nativescript-toast": "^1.4.6",
    "nativescript-uuid": "0.0.1",
    "nativescript-zxing": "^1.5.6",
    "reflect-metadata": "~0.1.10",
    "rxjs": "^5.5.11",
    "tns-core-modules": "^4.2.0",
    "tns-platform-declarations": "^5.1.2",
    "utf8": "^3.0.0",
    "zone.js": "^0.8.26"

"devDependencies": {
"@angular/compiler-cli": "^5.2.0",
"@ngtools/webpack": "~1.9.4",
"babel-traverse": "6.4.5",
"babel-types": "6.4.5",
"babylon": "6.4.5",
"codelyzer": "~4.0.2",
"copy-webpack-plugin": "~4.3.0",
"css-loader": "~0.28.7",
"extract-text-webpack-plugin": "~3.0.2",
"lazy": "1.0.11",
"nativescript-dev-sass": "~1.3.5",
"nativescript-dev-typescript": "~0.6.0",
"nativescript-dev-webpack": "^0.9.2",
"nativescript-worker-loader": "~0.8.1",
"raw-loader": "~0.5.1",
"resolve-url-loader": "~2.2.1",
"sass-loader": "~6.0.6",
"tslint": "~5.8.0",
"typescript": "~2.6.2",
"uglifyjs-webpack-plugin": "~1.1.6",
"webpack": "~3.10.0",
"webpack-bundle-analyzer": "^2.13.1",
"webpack-sources": "~1.1.0"
}

Trying to log in with microsoft aacount quen click Yes on Acces Infoscreen, a message apears "Safari cannot open the page because the address is invalid".
The invalid address is urn:ietf:wg:oauth:2.0:oob from the redirect uri property from TnsOaProviderOptionsMicrosoft

Azure Local Cache not shared to other webviews

I am able to get the Azure AD login system working great, but I am running into an issue where in other parts of my app I want to load Azure AD Authenticated websites such as Sharepoint, etc. and when doing so I am prompted by another Azure AD Login. If I log into the SharePoint Auth I am able to pass in and out of Azure sites with no issues. Am I missing a step to allow the plugin generated Webviews Local Cache to be shared with other Webviews in the app?

Which platform(s) does your issue occur on?

IOS and Android/ IOS Emulator and Android Emulator

Please, provide the following version numbers that your issue occurs with:

  • CLI: 5.2.4
  • Cross-platform modules: 5.2.0
  • Runtime(s):Android: 5.2.0, IOS: 5.2.0

Request changelog to be added

I am requesting that a changelog be created and kept up-to-date.

I see a major version bump was released but I can find no details as to what changed and how to migrate to the latest version (without having to spend a lot of time digging through commits and source code).

Not redirecting to app after google login - Reaches a page that says "Please copy this code, switch your app and paste it there" - After returning the auth code

config is something like this.

{
        openIdSupport: "oid-full",
        clientId:
            "<taken from google project config",
        redirectUri:
            "<taken from google project config>",
        urlScheme:
// Same as yours. Not sure where to get this from for me personally
            "com.googleusercontent.apps.932931520457-buv2dnhgo7jjjjv5fckqltn367psbrlb",
        scopes: ["email"]
    };


Which platform(s) does your issue occur on?

  • iOS

After logging in, it gives this as the result -

"Please copy this code, switch your app and paste it there"

Android blank page in login webview โ€” if I break config, it will display the error in the webview and work

I have a nativescript project and attempting to login using Oauth2.0. Now on iOS, everything works fine. In Android, whenever I click on login the webview is blank white, no error nothing on the console either.

  • if I copy-paste the 'url' of the webview for the authorization and take it on my desktop's browser -- all is good and it works
  • If I break the configuration of the request by either removing "scopes" or putting gibberish on the redirectURI, the webview displays the microsoft page with an error of what broke.
    
  • Tried Pie and Oreo on Nexus 5 + Pixel XL2
    
  • Updated Chrome/Webview to the latest version
    
  • Implemented custom URI schema for both Android and iOS following nativescript-oauth2 plugin guidelines.
    
  • Tested the webview to make sure it works with other sites
    

I've been trying things out and pretty much stuck on this for over 3 days now :(

In app manifest for the scheme:

`

    <meta-data android:name="SET_THEME_ON_LAUNCH" android:resource="@style/AppTheme" />

    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>

                <intent-filter>
        <action android:name="android.intent.action.VIEW"/>
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <!-- Custom Path data -->
        <data android:path="/auth" 

android:scheme="msala1ea6c64-3d77-4f2b-9baf-1cf72da2d376"/>

</activity>`

And of course there's the 'android:launchMode="singleTask">`

Oauth2 Config:

openIdSupport: 'oid-full', clientId: 'a1ea6c64-3d77-4f2b-9baf-1cf72da2d376', redirectUri: 'msala1ea6c64-3d77-4f2b-9baf-1cf72da2d376://auth', urlScheme: 'msala1ea6c64-3d77-4f2b-9baf-1cf72da2d376', scopes: ['openid', 'https://outlook.office.com/mail.read']

and msala1ea6c64-3d77-4f2b-9baf-1cf72da2d376://auth is registered in Azure as a redirectURI

TnsOAuthClient.logout() wish to have call back

According oauth.js:
line 38: TnsOAuthClient.prototype.logout = function (successPage){I'm notice there is no callback after logout, is it possible improve slightly to support callback after logout complete? It is useful when we wish to trigger go back landing page after logout complete.

After Google Signin my application doesn't close the frame of "google authenticator" and keep runing

Make sure to check the demo app(s) for sample usage

Done

Make sure to check the existing issues in this repository

Done

Which platform(s) does your issue occur on?

-Android

  • emulator or device. What type of device?
    device

Please, provide the following version numbers that your issue occurs with:

  • CLI: 5.0.1
  • Cross-platform modules: 5.0.1
  • Runtime(s): 5.0.0
  • Plugin(s):
"dependencies": {
    "@angular/animations": "6.1.10",
    "@angular/common": "6.1.10",
    "@angular/compiler": "6.1.10",
    "@angular/core": "6.1.10",
    "@angular/forms": "6.1.10",
    "@angular/http": "6.1.10",
    "@angular/platform-browser": "6.1.10",
    "@angular/platform-browser-dynamic": "6.1.10",
    "@angular/router": "6.1.10",
    "@danvick/ngx-translate-nativescript-loader": "^2.0.0",
    "@ngx-translate/core": "^11.0.1",
    "@progress-nativechat/nativescript-nativechat": "2.0.3",
    "kinvey-nativescript-sdk": "3.11.6",
    "nativescript-accelerometer": "2.0.1",
    "nativescript-angular": "6.2.0",
    "nativescript-auto-fit-text": "^1.0.0",
    "nativescript-background-http": "3.3.0",
    "nativescript-camera": "4.0.3",
    "nativescript-checkbox": "^3.0.3",
    "nativescript-fancyalert": "^3.0.6",
    "nativescript-fresco": "5.1.0",
    "nativescript-geolocation": "4.3.1",
    "nativescript-imagepicker": "6.0.4",
    "nativescript-intl": "3.0.0",
    "nativescript-iqkeyboardmanager": "1.3.0",
    "nativescript-oauth2": "^1.1.3",
    "nativescript-social-share": "1.5.1",
    "nativescript-theme-core": "1.0.4",
    "nativescript-toast": "^1.4.6",
    "nativescript-ui-autocomplete": "3.10.1",
    "nativescript-ui-calendar": "3.9.0",
    "nativescript-ui-chart": "3.9.1",
    "nativescript-ui-dataform": "3.7.4",
    "nativescript-ui-gauge": "3.7.1",
    "nativescript-ui-listview": "3.7.2",
    "nativescript-ui-sidedrawer": "5.0.0",
    "reflect-metadata": "0.1.12",
    "rxjs": "6.2.2",
    "rxjs-compat": "^6.1.0",
    "tns-core-modules": "5.0.1",
    "zone.js": "0.8.26"
  },
  "devDependencies": {
    "@angular/compiler-cli": "~6.1.0",
    "@ngtools/webpack": "^6.2.7",
    "babel-traverse": "6.26.0",
    "babel-types": "6.26.0",
    "babylon": "6.18.0",
    "lazy": "1.0.11",
    "nativescript-dev-typescript": "0.7.2",
    "nativescript-dev-webpack": "0.17.0",
    "tns-platform-declarations": "4.2.0",
    "typescript": "~2.7.2"
  }

Please, tell us how to recreate the issue in as much detail as possible.

when i chose fb login all work fine but with google a new frame show then after login this frame dosen't close and keep runing my application there (so 2 instance of application)
1-click google signin button
2-finish google sign in process
3-frame dosen't close and run one more instance of my application

Is there any code involved?

  • AndroidManifest:
<application android:name="com.tns.NativeScriptApplication" android:allowBackup="true" android:icon="@drawable/icon" android:label="@string/app_name" android:theme="@style/AppTheme" android:launchMode="singleTask">
        <activity android:name="com.tns.NativeScriptActivity" android:label="@string/title_activity_kimera" android:configChanges="keyboardHidden|orientation|screenSize" android:theme="@style/LaunchScreenTheme">
            <meta-data android:name="SET_THEME_ON_LAUNCH" android:resource="@style/AppTheme" />
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:path="/oauth2redirecte" android:scheme="com.googleusercontent.apps.xxxxxxxxxx-i1gr5u7a8ece75n6ibjso47c3a2bql05" />
            </intent-filter>
        </activity>
        <activity android:name="com.tns.ErrorReportActivity" />
    </application>
  • Main.ts:
    platformNativeScriptDynamic().bootstrapModule(AppModule);
  • App.component.html:
    <page-router-outlet></page-router-outlet>
  • Login Component:
this.authService
		  .OauthLoginToken(provider)
		  .then((result: ITnsOAuthTokenResult) => { 
				console.log(result.accessToken);
				console.log("test");
					this.messages.push(this.translateService.instant('backendcode.'+422)); 	
		}).catch(()=>{
			this.errors.push(this.translateService.instant('backendcode.499'));
			});
  • Login service:
public async OauthLoginToken(providerType): Promise<ITnsOAuthTokenResult> {
    this.client = new TnsOAuthClient(providerType);
    return  new Promise<ITnsOAuthTokenResult>((resolve, reject) => {
       this.client.loginWithCompletion(
        (tokenResult: ITnsOAuthTokenResult, error) => {
          if (error) {
            console.log("reject");
            reject(error);
          } else {
            console.log("resolve");
            resolve(tokenResult);
          }
        }
      );
    })
  }

Can I connect Identity Server 4 with this plugin?

Hello I am searching about 1 week. I am new about Identity Server and I did not understand clearly working mechanism about Identity Server.

Accutally I have developed a demo app with Xamarin for connecting to Identity Server 4 with using C# Oidc Client and I succesfully connected. But I need to develop a mobile demo app with NativeScript for comparing two platforms performance. I know to use Nativescript with Vue. I need really help. Because I do not have so much times.

My questions about "Can I connect Identity Server with this plugin or not". I have used below params when connect to Identitiy Server with Xamarin. I have examined your plugin but I did not find params as below.

var _OidcClientOptions = new OidcClientOptions
            {
                Authority = "https://auth.......",
                ClientId = "...........",
                ClientSecret = "..........",
                Scope = "openid profile email api",
                RedirectUri = "clients://callback",
                PostLogoutRedirectUri = "clients://callback",
            };

C# plugin URL is here

Thank you very much in advance.

Custom authorizationCodeFromRedirectUrl

Hi! I'm trying to use vk.com oauth in my app, but code in redirected page located not in url query, but in url hash part, so I want to use some custom function that will parse code from redirect url.

Custom provider with ADFS OIDC minimizes app

Which platform(s) does your issue occur on?

  • Android
  • Android 9
  • Xiaomi Mi A1

Please, provide the following version numbers that your issue occurs with:

  • CLI: 5.3.1
  • Cross-platform modules: 5.3.1
  • Runtime(s): 5.0.0
  • Plugin(s):

  "dependencies": {
    "nativescript-theme-core": "^1.0.4",
    "nativescript-unit-test-runner": "^0.3.4",
    "nativescript-oauth2": "file:../src",
    "tns-core-modules": "^5.1.1"
  },
  "devDependencies": {
    "jasmine-core": "^2.5.2",
    "karma": "^1.3.0",
    "karma-jasmine": "^1.0.2",
    "karma-nativescript-launcher": "^0.4.0",
    "nativescript-css-loader": "~0.26.1",
    "nativescript-dev-typescript": "~0.7.2",
    "nativescript-dev-webpack": "~0.17.0",
    "tns-platform-declarations": "^4.2.0",
    "tslint": "~5.4.3",
    "typescript": "3.1.1"
  },

Please, tell us how to recreate the issue in as much detail as possible.

When you sign in it redirects back to the app for a moment and then minimizes the app (I think it actually crashes).

Is there any code involved?

I changed the demo-custom-provider apps TnsOaProviderMyCustomProvider and TnsOaMyCustomProviderOptions config information to point to our local ADFS.

function configureOAuthProviderMyCustomProvider(): TnsOaProvider {
  const customProviderOptions: TnsOaMyCustomProviderOptions = {
    openIdSupport: "oid-full",
    clientId: environment.clientId,
    redirectUri: constants.redirectUrl,
    urlScheme: environment.urlSchema,
    scopes: ["openid"]
  };
  const customProvider = new TnsOaProviderMyCustomProvider(customProviderOptions);
  return customProvider;
}
export class TnsOaProviderMyCustomProvider implements TnsOaProvider {
    public options: TnsOaProviderOptions;
    public openIdSupport: OpenIdSupportFull = "oid-full";
    public providerType = "myCustomProvider";
    public authority = "https://fssa.mycompany.co.za/adfs";
    public tokenEndpointBase = "https://fssa.mycompany.co.za/adfs";
    public authorizeEndpoint = "/oauth2/authorize";
    public revokeEndpoint: string = "https://fssa.mycompany.co.za/adfs/oauth2/logout";
    public tokenEndpoint = "/oauth2/token";
    public cookieDomains = ["fssa.mycompany.co.za"];

    constructor(options: TnsOaMyCustomProviderOptions) {
        this.options = options;
    }

    public parseTokenResult(jsonData): ITnsOAuthTokenResult {
        return jsonData;
    }
}

I added the intent-filters to the AndroidManifest file

<intent-filter>
	 <action android:name="android.intent.action.VIEW"/>
	 <category android:name="android.intent.category.DEFAULT" />
	 <category android:name="android.intent.category.BROWSABLE" />
	 <data android:scheme="myappschema" android:path="/callback"/>
</intent-filter>

Nativescript ng router issue

Hi!

Thanks for the plugin, it works as expected but I can't redirect to another page on token result:

this.authService
.tnsOauthLogin("facebook")
.then((result: ITnsOAuthTokenResult) => {
console.log("back to app component with token" + result.accessToken);
this.routerextension.navigate(["/home"]);
});

Can this library silently refresh the access token and keep the user perpetually signed-in?

Dear Alexander, greetings from all our team, we really appreciate your great work on this library.

Just a question:
We want to use the recommended OIDC technique for mobile apps which is the Authorization Code Grant Flow with PKCE and having the user sign in through the mobile browser.
We gathered from your documentation that this library implements this flow, correct?

The question is: with this library is it possible to keep the user perpetually signed in to the NativeScript app as long as the user is still signed into the OIDC provider from the mobile browser? Perhaps through some sort of "silent" token refresh mechanism whenever the existing token is about to expire? We need some guidance.

Another question on the side: Do you plan on pursuing an OidC certification for this library in the future?

Best wishes!

get custom open url with parameter

Hello
First of all thanks for this nice plugin.
I've installed and implemented this plugin successful. The openID login process works fine for my Providers and custom Providers.

Now I want to start my app by an e-mail or by a weblink with given request-parameters like
myApp://?paramOne=one&paramTwo=2
I've added the url scheme ('myApp') in my info.plist and the app is starting by clicking.

How can I get the starting url and the parameters? Because of the appDelegate from the oauth2 plugin I can't implement my own delegate to handle the url.

Is there PKCE support?

Thank you for a great plugin!

Question question, does this plugin support "Authorization Code Flow with PKCE"? I have noticed that the class TnsOAuthState does have a codeVerifier but it is set to '' during the object creation.

Is there maybe sample code that shows the use of PKCE?

Otherwise, would it be possible to have an option to pass in custom parameters?

Can't use other tenant then common for the login.microsoftonline.com

Make sure to check the demo app(s) for sample usage

Does not seem like there is a sample for this.

Make sure to check the existing issues in this repository

The issue does not seem to be present at this time.

If the demo apps cannot help and there is no issue for your problem, tell us about it

I want to use for example "https://login.microsoftonline.com/contoso.onmicrosoft.com" instead of "https://login.microsoftonline.com/common" as login URL but if i try to change it in the node_modules/nativescript-oauth2/providers/providers.js the app just closes when clicking sign in.

Which platform(s) does your issue occur on?

  • Android
  • Android Pie 9.0
  • emulator

Please, provide the following version numbers that your issue occurs with:

  • CLI: 5.2.4
  • Cross-platform modules: 5.2.2
  • Runtime(s): tns-android = 5.2.1
  • Plugin(s): nativescript-oauth2: ^1.4.1,

Please, tell us how to recreate the issue in as much detail as possible.

In the node_modules/nativescript-oauth2/providers/providers.js file edit the "https://login.microsoftonline.com/common" to "https://login.microsoftonline.com/{tenant}"

2FA with Azure AD

Great job on the plugin! All is good with one exception: guest accounts in AAD with multi-factor authentication enabled doesnโ€™t seem to work.

The out-of-app browser opens, I enter the guest email then password, but it should then send a verification code to my phone and prompt me. It just hangs after I submit the password.

I verified the server side in Postman so it shouldnโ€™t be on the Azure app side.

For accounts with no MFA, everything works perfectly. The browser passes back the response and the access_token is used with other service calls.

Thoughts?

Thanks!

Error after redirect from any social authentication in this plugin

I am running {N} 6.1 and I am getting this error in android in native script angular.

This error is producing after redirect from any social authentication like Google, Microsoft.

Steps to produce an error: I have added msal and my client id into the redirect URI and also into androidmanifest.xml file into URL scheme, the first time it will redirect you to the app fine but after that, once you logged in then it will close the app if you will tap on login button again and after that you will open the app again then it will re-run the pending code and then will give you access token and redirect code will generate but redirection doesn't happen.

nhandled Promise rejection: Cannot read property 'loginCompletion' of null ; Zone: <root> ; Task: Promise.then ; Value: TypeError: Cannot read property 'loginCompletion' of null TypeError: Cannot read property 'loginCompletion' of null
JS:     at TnsOAuthLoginSubController.push.../node_modules/nativescript-oauth2/tns-oauth-login-sub-controller.js.TnsOAuthLoginSubController.completeLoginWithTokenResponseError file:///node_modules/nativescript-oauth2/tns-oauth-login-sub-controller.js:75:0
JS:     at file:///node_modules/nativescript-oauth2/tns-oauth-native-view-controller.js:35:0
JS:     at responseCompletion file:///node_modules/nativescript-oauth2/tns-oauth-login-sub-controller.js:57:0
JS:     at file:///node_modules/nativescript-oauth2/tns-oauth-client-connection.js:177:0
JS:     at ZoneDelegate.push.../node_modules/nativescript-angular/zone-js/dist/zone-nativescript.js.ZoneDelegate.invoke file:///node_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:388:0
JS:     at Zone.push.../node_modules/nativescript-angular/zone-js/dist/zone-nativescript.js.Zone.run (file:///da...

Thank you.

Close WebView by manual

Make sure to check the demo app(s) for sample usage

yes

Make sure to check the existing issues in this repository

yes

If the demo apps cannot help and there is no issue for your problem, tell us about it

Please, ensure your title is less than 63 characters long and starts with a capital
letter.

Which platform(s) does your issue occur on?

-Both

Please, provide the following version numbers that your issue occurs with:

  • CLI: 5.0.2
  • Cross-platform modules: 5.0.2
  • Runtime(s): tns-android : 5.0.0 ; tns-ios: 5.0.0
  • Plugin(s): 1.2.0

Please, tell us how to recreate the issue in as much detail as possible.

Sometimes, user take for a long time to login with oauth and then switch to other app. In this case, Can I close manual WebView to do something else ? and if we could , how can i do that ?
Thanks

Support for multiple flows

Hi and thanks for this package.

I've created a custom provider for our auth server that requires, for this kind of application, a Hybrid (or Implicit) flow. This means that the token is received as fragment in the redirect url (custom url scheme).

We succeeded in letting this work by overriding the getAuthUrlStr() method. The problem is that when we get the redirection back, it seems that the loginWithCompletion callback doesn't fire.

Any workaround? Thanks.

Angular cannot navigate on Android after login

Which platform(s) does your issue occur on?

Android, latest SDK, Pixel 2XL

Please, provide the following version numbers that your issue occurs with:

  • CLI: 5.2.0
  • Cross-platform modules: 5.1.2
  • Runtime(s): 5.2.0 (both)
  • Plugin(s):
    "@nativescript/schematics": "~0.4.0", "nativescript-dev-typescript": "~0.7.0", "nativescript-dev-webpack": "~0.18.0", "typescript": "^3.1.6", "@angular/compiler-cli": "~7.0.0", "@ngtools/webpack": "~7.0.0"

Please, tell us how to recreate the issue in as much detail as possible.

Using the angular demo as boilerplate code, add navigation in resolve callback. Debug on Android

Is there any code involved?

export class HomeComponent implements OnInit{
	...
	...
	...

	login(){      
      this.authService.hnOauthLogin()
        .then((result: ITnsOAuthTokenResult) => {
            console.log("back to app component with token: " + result.accessToken);
            this.routerExtensions.navigate(["dashboard"], {clearHistory: true});
        })
        .catch((err) =>{
            console.log("back to app component with error: " + err);
        });
    }
}

Loginwithcompletion is not finishing , after google login it redirects to google home page

export function configureOAuthProviders() {
console.log('Configuring auth');
const googleProvider = configureOAuthProviderGoogle();
configureTnsOAuth([googleProvider])
}

export function tnsOauthLogin(providerType) {
const client = new TnsOAuthClient(providerType);
console.log(client)
console.log('calling')
client.loginWithCompletion(
(tokenResult: ITnsOAuthTokenResult, error) => {
if (error) {
console.error("back to main page with error: ");
console.error(error);

  } else {
    console.log("back to main page with access token: ");
    console.log(tokenResult);
   
  }
}

);

Even though at manifest file I have added singleTask and path as :/auth,
my above code is not returnning the accesToken

Please help me

Android compilation error

During compilation on android got this error (on ios works):

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformDexArchiveWithDexMergerForDebug'.
> com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: 
  The number of method references in a .dex file cannot exceed 64K.
  Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html

Edited:

Fixed in app.gradle:

android {
  defaultConfig {
    multiDexEnabled true
  }
}

Sorry

ios, google login, vue, not redirect to app

Dear All,
I tried this module, but after success login in google, just back to google.com, not back to my app.

any miss in my configure ?

The sample here
https://github.com/adehuh/oauth-m2.git

<template>
     <StackLayout height="100%" width="100%">
   
<Button text="Login" class="btn btn-primary "  @tap="openLogin" />

  </StackLayout>
</template>

<script>
import { configureTnsOAuth } from "nativescript-oauth2";
import {
  TnsOaProvider,
  TnsOaProviderOptionsFacebook,
  TnsOaProviderFacebook,
  TnsOaProviderOptionsGoogle,
  TnsOaProviderGoogle,
  TnsOaProviderOptionsMicrosoft,
  TnsOaProviderMicrosoft
} from "nativescript-oauth2/providers";
import { TnsOAuthClient, ITnsOAuthTokenResult } from "nativescript-oauth2";
export default {
  components: {},
  mounted() {
    console.log(111111111111111111111111111);
    configureTnsOAuth([this.configureOAuthProviderGoogle()]);
    console.log(222222);
  },
  data() {
    return {};
  },
  methods: {
    openLogin() {
      console.log(">>>>>>>>");
      var providerType = "google"; //'google', 'facebook', 'microsoft',
      this.tnsOauthLogin(providerType);
    },
    tnsOauthLogin(providerType) {
     const client = new TnsOAuthClient(providerType);
      client.loginWithCompletion(function(tokenResult, error) {
        if (error) {
          console.error("back to main page with error: ");
          console.error(error);
        } else {
          console.log("back to main page with access token: ");
          console.log(tokenResult);
        }
      });
    },
    configureOAuthProviderGoogle() {
      const googleProviderOptions = {
        openIdSupport: "oid-full",
        clientId:
          "XXXXX.apps.googleusercontent.com",
        redirectUri: "com.googleusercontent.apps.XXXX:/auth",// kay berhasil;
        //redirectUri: "http://localhost:9000/oauth2/authorization/oidc",
        urlScheme:
          "com.googleusercontent.apps.XXX",
        scopes: ["email"]
      };
      const googleProvider = new TnsOaProviderGoogle(googleProviderOptions);
      return googleProvider;
    }
  }
};
</script>
<key>CFBundleURLTypes</key>
    <array>
		<dict>
		<key>CFBundleTypeRole</key>
            <string>Editor</string>
            <key>CFBundleURLName</key>
            <string>org.nativescript.application</string>
			<key>CFBundleURLSchemes</key>
			<array>
				<string>com.googleusercontent.apps.XXXXXX</string>		
			</array>
		</dict>
    </array>
</dict>
</plist>

Which platform(s) does your issue occur on?

  • iOS

Sincerely,
adehuh

Debug network with chrome devtools

Please, tell us how to recreate the issue in as much detail as possible.

When starting the debug session either using TNS CLI or using NativeScript Sidekick, the debugger session starts but I cannot see any network requests at all. Does this plugin support network debugging? Looks like plugin authors need to support it, according to https://docs.nativescript.org/tooling/debugging/chrome-devtools#plugin-authors-guide

Or could this be related to the http client?
import { NativeScriptHttpClientModule } from "nativescript-angular/http-client";

Which platform(s) does your issue occur on?

  • iOS
  • Both emulator and device.

What type of device?

  • iPhone 8 tested

Please, provide the following version numbers that your issue occurs with:

  • CLI:
    tns --version
    5.1.1

  • Cross-platform modules:
    [email protected]

  • Runtime(s):
    "tns-ios": { "version": "5.1.0" }

  • Plugin(s):
    "dependencies": {
    "@angular/animations": "~7.1.0",
    "@angular/common": "~7.1.0",
    "@angular/compiler": "~7.1.0",
    "@angular/core": "~7.1.0",
    "@angular/forms": "~7.1.0",
    "@angular/http": "~7.1.0",
    "@angular/platform-browser": "~7.1.0",
    "@angular/platform-browser-dynamic": "~7.1.0",
    "@angular/router": "~7.1.0",
    "nativescript-angular": "~7.1.0",
    "nativescript-oauth2": "^1.3.1",
    "nativescript-theme-core": "~1.0.4",
    "nativescript-toast": "1.4.6",
    "nativescript-ui-listview": "5.1.1",
    "nativescript-ui-sidedrawer": "5.1.0",
    "reflect-metadata": "~0.1.10",
    "rxjs": "~6.3.0",
    "rxjs-compat": "^6.3.3",
    "tns-core-modules": "~5.1.0",
    "zone.js": "~0.8.18"
    },
    "devDependencies": {
    "@nativescript/schematics": "~0.5.0",
    "nativescript-dev-typescript": "~0.7.0",
    "nativescript-dev-webpack": "~0.19.0",
    "@angular/compiler-cli": "~7.1.0",
    "@ngtools/webpack": "~7.1.0"
    },

Is there any code involved?

Oauth2 plugin code is executing networks calls and it is working, but no calls are visible in Chrome devtools.

logout not implemented correctly

According to the oidc specification the end_session_endpoint should be called with the id token.
https://openid.net/specs/openid-connect-session-1_0.html#RPLogout

identityserver4 has implemented this as follows:
http://docs.identityserver.io/en/latest/endpoints/endsession.html#refendsession

But when the login method is called only the refresh token will be revoked on the revocation_endpoint, and the cookies and tokens are removed locally.

public logout() {
    this.callRevokeEndpoint();
    this.removeCookies();
    this.removeToken();
  }
public startTokenRevocation() {
    // call revoke token here
    const revokeUrl =
      this.client.provider.authority + this.client.provider.revokeEndpoint;
    const headers = {
      "Content-Type": "application/x-www-form-urlencoded"
    };
    const body = querystring.stringify({
      token: this.client.tokenResult.refreshToken
    });

    http
      .request({
        url: revokeUrl,
        method: "POST",
        headers: headers,
        content: body
      })
      .then(
        (response: http.HttpResponse) => {
          if (response.statusCode !== 200) {
            this.completion(
              null,
              response,
              new Error(`Failed logout with status ${response.statusCode}.`)
            );
          } else {
            this.completion(null, response, null);
          }
        },
        error => this.completion(null, null, error)
      );
  }

This means that a call to the login will result in new valid tokens without the need to fill in any credentials (For the provider you are still logged in)

This is not the expected/desired behaviour, as the end user will experience this as not being logged-out at all.
It also means that the end user cannot logout and then login as a different user.

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[TnsOAuthClientAppDelegate window]: unrecognized selector sent to instance 0x282ec2510

Which platform(s) does your issue occur on?

  • iOS/Android
  • iOS/Android 6.0.1
  • emulator or device. What type of device? Device

Please, provide the following version numbers that your issue occurs with:

{
  "nativescript": {
    "id": "ar.waisoft.sampayo",
    "tns-android": {
      "version": "6.0.0"
    },
    "tns-ios": {
      "version": "6.0.1"
    }
  },
  "description": "NativeScript Application",
  "license": "SEE LICENSE IN <your-license-filename>",
  "repository": "<fill-your-repository-here>",
  "dependencies": {
    "@angular/animations": "~8.0.0",
    "@angular/common": "~8.0.0",
    "@angular/compiler": "~8.0.0",
    "@angular/core": "~8.0.0",
    "@angular/forms": "~8.0.0",
    "@angular/http": "~8.0.0-beta.10",
    "@angular/platform-browser": "~8.0.0",
    "@angular/platform-browser-dynamic": "~8.0.0",
    "@angular/router": "~8.0.0",
    "nativescript-angular": "~8.0.0",
    "nativescript-block-ui": "^1.0.0",
    "nativescript-fancyalert": "^3.0.8",
    "nativescript-localstorage": "^2.0.0",
    "nativescript-mercadopago-px": "^1.1.5",
    "nativescript-oauth2": "^2.1.0",
    "nativescript-theme-core": "^1.0.6",
    "nativescript-toast": "^2.0.0",
    "nativescript-ui-listview": "^7.0.1",
    "reflect-metadata": "~0.1.12",
    "rxjs": "~6.5.0",
    "tns-core-modules": "~6.0.0",
    "zone.js": "~0.9.1"
  },
  "devDependencies": {
    "@angular/compiler-cli": "~8.0.0",
    "@ngtools/webpack": "~8.0.0",
    "nativescript-dev-webpack": "~1.0.0",
    "node-sass": "^4.12.0",
    "typescript": "~3.4.0"
  },
  "gitHead": "f28dbc60d74dd2cef4b645afd8fdd63bbb12c73e",
  "readme": "NativeScript Application"
}

Please, tell us how to recreate the issue in as much detail as possible.

-[TnsOAuthClientAppDelegate window]: unrecognized selector sent to instance 0x282ec2510 *** JavaScript call stack: ( 0 UIApplicationMain@[native code] 1 _start@file:///node_modules/tns-core-modules/application/application.js:277:0 2 run@file:///node_modules/tns-core-modules/application/application.js:305:0 3 bootstrapNativeScriptApp@file:///node_modules/nativescript-angular/platform-common.js:205:0 4 bootstrapApp@file:///node_modules/nativescript-angular/platform-common.js:106:0 5 bootstrapModule@file:///node_modules/nativescript-angular/platform-common.js:90:0 6 @file:///app/bundle.js:626:144 7 ./main.ts@file:///app/bundle.js:631:34 8 __webpack_require__@file:///src/webpack/bootstrap:750:0 9 checkDeferredModules@file:///src/webpack/bootstrap:43:0 10 webpackJsonpCallback@file:///src/webpack/bootstrap:30:0 11 anonymous@file:///app/bundle.js:2:61 12 evaluate@[native code] 13 moduleEvaluation@:1:11 14 promiseReactionJob@:1:11 ) *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[TnsOAuthClientAppDelegate window]: unrecognized selector sent to instance 0x282ec2510' *** First throw call stack: (0x205dc298c 0x204f9b9f8 0x205cdf1c8 0x2326f2220 0x205dc81d4 0x205dc9e6c 0x1017d31a4 0x1017d3334 0x205d33a28 0x205d339f4 0x205d32ee8 0x205d32b94 0x205cac474 0x205d32644 0x20671b6f4 0x2324d6378 0x2324d8e44 0x232558698 0x2324d893c 0x2324df784 0x2324d7fac 0x232551280 0x23254a804 0x232565004 0x2325652a0 0x2058017d4 0x2057a65dc 0x208779040 0x208778cdc 0x208779294 0x205d54728 0x205d546a8 0x205d53f90 0x205d4eecc 0x205d4e7c0 0x207f4f79c 0x2326c6c38 0x1026d4044 0x1026d1780 0x1026d127c 0x101b74f54 0x1026d0488 0x1026ce804 0x1026ce804 0x1026ce804 0x1026ce804 0x1026ce804 0x1026ce804 0x1026ce804 0x1026ce804 0x1026ce804 0x1026ce764 0x1026ce804 0x1026ba2ac 0x102347ebc 0x10251cf98 0x101b8cec8 0x101cec9a0 0x1026d01ec 0x1026ce804 0x1026ce804 0x1026ba2ac 0x102347ebc 0x10251d164 0x101ce5d0c 0x101b83d88 0x101bf1f50 0x101270<\M-b\M^@\M-&> NativeScript caught signal 6. Native Stack: 1 0x101bf0b18 sig_handler(int) 2 0x2059d29ec <redacted> 3 0x2059d8094 <redacted> 4 0x2058b7ea8 abort 5 0x204f84788 __cxa_bad_cast 6 0x204f84934 <redacted> 7 0x204f9be00 <redacted> 8 0x204f90838 <redacted> 9 0x204f908c4 std::terminate() 10 0x2058017e8 <redacted> 11 0x2057a65dc <redacted> 12 0x208779040 <redacted> 13 0x208778cdc <redacted> 14 0x208779294 <redacted> 15 0x205d54728 <redacted> 16 0x205d546a8 <redacted> 17 0x205d53f90 <redacted> 18 0x205d4eecc <redacted> 19 0x205d4e7c0 CFRunLoopRunSpecific 20 0x207f4f79c GSEventRunModal 21 0x2326c6c38 UIApplicationMain 22 0x1026d4044 ffi_call_SYSV 23 0x1026d1780 ffi_call_int 24 0x1026d127c ffi_call 25 0x101b74f54 NativeScript::FunctionWrapper::call(JSC::ExecState*) 26 0x1026d0488 llint_entry 27 0x1026ce804 llint_entry 28 0x1026ce804 llint_entry 29 0x1026ce804 llint_entry 30 0x1026ce804 llint_entry 31 0x1026ce804 llint_entry JS Stack: 1 UIApplicationMain@[native code] 2 _start@file:///node_modules/tns-core-modules/application/application.js:277:0 3 run@file:///node_modules/tns-core-modules/application/application.js:305:0 4 bootstrapNativeScriptApp@file:///node_modules/nativescript-angular/platform-common.js:205:0 5 bootstrapApp@file:///node_modules/nativescript-angular/platform-common.js:106:0 6 bootstrapModule@file:///node_modules/nativescript-angular/platform-common.js:90:0 7 @file:///app/bundle.js:626:144 8 ./main.ts@file:///app/bundle.js:631:34 9 __webpack_require__@file:///src/webpack/bootstrap:750:0 10 checkDeferredModules@file:///src/webpack/bootstrap:43:0 11 webpackJsonpCallback@file:///src/webpack/bootstrap:30:0 12 anonymous@file:///app/bundle.js:2:61 13 evaluate@[native code] 14 moduleEvaluation@:1:11 15 promiseReactionJob@:1:11

Demo Angular not working ... Type Error

Make sure to check the demo app(s) for sample usage

I was trying to check the demo angular app but it's not working for me.

Make sure to check the existing issues in this repository

There is no existing issue currently.

If the demo apps cannot help and there is no issue for your problem, tell us about it

Please, ensure your title is less than 63 characters long and starts with a capital
letter.
I was just trying to check the demo angular app and doing tns run android but it's giving me type error below mentioned.

Which platform(s) does your issue occur on?

  • Android
  • Android Pie (9)
  • emulator or device. What type of device?
    One Plus 6 Mobile

Please, provide the following version numbers that your issue occurs with:

  • CLI: 6.1.0
  • Cross-platform modules: 6.1.1
  • Runtime(s): 6.1.0
  • Plugin(s): 2.1.1

Please, tell us how to recreate the issue in as much detail as possible.

Just run the demo angular with Nativescript Sidekick.

Is there any code involved?

[19-09-23 08:32:38.085] (CLI) ../src/pkce-util.ios.ts(14,23): error TS2304: Cannot find name 'NSData'.
[19-09-23 08:32:38.085] (CLI) ../src/pkce-util.ios.ts(14,32): error TS2304: Cannot find name 'NSString'.
[19-09-23 08:32:38.085] (CLI) ../src/pkce-util.ios.ts(14,89): error TS2304: Cannot find name 'NSUTF8StringEncoding'.
[19-09-23 08:32:38.085] (CLI) ../src/pkce-util.ios.ts(15,25): error TS2304: Cannot find name 'NSMutableData'.
[19-09-23 08:32:38.085] (CLI) ../src/pkce-util.ios.ts(15,41): error TS2304: Cannot find name 'NSMutableData'.
[19-09-23 08:32:38.085] (CLI) ../src/pkce-util.ios.ts(16,3): error TS2304: Cannot find name 'CC_SHA256'.
[19-09-23 08:32:38.085] (CLI) ../src/pkce-util.ios.ts(20,41): error TS2304: Cannot find name 'NSData'.
[19-09-23 08:32:38.085] (CLI) ../src/pkce-util.ts(2,45): error TS2339: Property 'util' does not exist on type 'typeof android'.
[19-09-23 08:32:38.085] (CLI) ../src/pkce-util.ts(2,75): error TS2339: Property 'util' does not exist on type 'typeof android'.
[19-09-23 08:32:38.085] (CLI) ../src/pkce-util.ts(2,108): error TS2339: Property 'util' does not exist on type 'typeof android'.
[19-09-23 08:32:38.085] (CLI) ../src/pkce-util.ts(5,29): error TS2339: Property 'create' does not exist on type 'ArrayConstructor'.
[19-09-23 08:32:38.085] (CLI) ../src/pkce-util.ts(6,7): error TS2304: Cannot find name 'java'.
[19-09-23 08:32:38.085] (CLI) ../src/pkce-util.ts(7,18): error TS2339: Property 'util' does not exist on type 'typeof android'.
[19-09-23 08:32:38.085] (CLI) ../src/pkce-util.ts(11,26): error TS2304: Cannot find name 'java'.
[19-09-23 08:32:38.085] (CLI) ../src/pkce-util.ts(12,29): error TS2304: Cannot find name 'java'.
[19-09-23 08:32:38.085] (CLI) ../src/pkce-util.ts(14,18): error TS2339: Property 'util' does not exist on type 'typeof android'.
[19-09-23 08:32:38.085] (CLI) ../src/tns-oauth-native-view-controller.ios.ts(12,56): error TS2304: Cannot find name 'NSObject'.
[19-09-23 08:32:38.085] (CLI) ../src/tns-oauth-native-view-controller.ios.ts(13,14): error TS2304: Cannot find name 'SFSafariViewControllerDelegate'.
[19-09-23 08:32:38.085] (CLI) ../src/tns-oauth-native-view-controller.ios.ts(14,34): error TS2304: Cannot find name 'SFSafariViewControllerDelegate'.
[19-09-23 08:32:38.085] (CLI) ../src/tns-oauth-native-view-controller.ios.ts(17,33): error TS2304: Cannot find name 'SFSafariViewController'.
[19-09-23 08:32:38.085] (CLI) ../src/tns-oauth-native-view-controller.ios.ts(46,33): error TS2304: Cannot find name 'SFSafariViewController'.
[19-09-23 08:32:38.085] (CLI) ../src/tns-oauth-native-view-controller.ios.ts(47,7): error TS2304: Cannot find name 'NSURL'.
[19-09-23 08:32:38.085] (CLI) ../src/tns-oauth-native-view-controller.ios.ts(85,17): error TS2304: Cannot find name 'SFSafariViewController'.
[19-09-23 08:32:38.085] (CLI) ../src/tns-oauth-utils.ts(129,10): error TS2552: Cannot find name 'NSArray'. Did you mean 'Array'?

Cannot read property 'loginCompletion' of null

Which platform(s) does your issue occur on?

  • Android
  • Target: Android 7.0. API: 24
  • Emulator. Pixel 2 API 24

Please, provide the following version numbers that your issue occurs with:

$ tns --version
5.4.2
  • Cross-platform modules: "version": "5.2.2"
    (check the 'version' attribute in the node_modules/tns-core-modules/package.json file in your project)

  • Runtime(s): "version": "5.2.0"
    (look for the "tns-android" and "tns-ios" properties in the package.json file of your project)

  • Plugin(s): (look for the version numbers in the package.json file of your project and paste your dependencies and devDependencies here)

    "dependencies": {
        "@angular/animations": "~7.2.0",
        "@angular/common": "~7.2.0",
        "@angular/compiler": "~7.2.0",
        "@angular/core": "~7.2.0",
        "@angular/forms": "~7.2.0",
        "@angular/http": "~7.2.0",
        "@angular/platform-browser": "~7.2.0",
        "@angular/platform-browser-dynamic": "~7.2.0",
        "@angular/router": "~7.2.0",
        "nativescript-angular": "~7.2.1",
        "nativescript-oauth2": "^1.5.3",
        "nativescript-theme-core": "~1.0.4",
        "reflect-metadata": "~0.1.12",
        "rxjs": "~6.3.0",
        "tns-core-modules": "~5.2.0",
        "zone.js": "~0.8.26"
    },
    "devDependencies": {
        "@angular/compiler-cli": "~7.1.0",
        "@nativescript/schematics": "~0.5.0",
        "@ngtools/webpack": "~7.1.0",
        "nativescript-dev-typescript": "~0.8.0",
        "nativescript-dev-webpack": "~0.20.0"
    },

Please, tell us how to recreate the issue in as much detail as possible.

$ git clone https://github.com/napolev/nativescript-oauth2-issue
$ cd nativescript-oauth2-issue
$ npm i
$ tns platform clean android
$ tns devices
$ tns run android [--device <device-id>]

Once the app is running on the phone:

  1. login with any Google account
  2. you will see the access token on the console
  3. logout
  4. login again
  5. you will see some errors on the console from now on any subsequent logins

Is there any code involved?

Preview: https://www.youtube.com/watch?v=T-6qj1SAsnk

Github repo: https://github.com/napolev/nativescript-oauth2-issue

I think the problem is on the following file:

/demo-angular/node_modules/nativescript-oauth2/tns-oauth-login-sub-controller.js

Preview

where after the first login/logout, when trying to login again, the variable: this.authState is null and it is getting asked for: this.authState.loginCompletion which throws the exception:

Unhandled Promise rejection: Cannot read property 'loginCompletion' of null ;
Zone: <root> ; Task: Promise.then ; Value: TypeError:
Cannot read property 'loginCompletion' of null TypeError: Cannot read property 'loginCompletion' of null

Google logging problem

Hi,
First of all thx and congratulation for this amazing plugin! <3
Detail of my problem:
After login i dont get the token and the web frame dosent close

Custom OAuth configuration

I think that Custom OAuth configuration should be more configurable.
Could you consider some improvements in tns-oauth-utils.js

  1. Add support of offline access_type in getAuthUrlStr()
    like params["access_type"] = provider.options.access_type || "online";

  2. Make response_mode parameter optional - for some provider this is unexpected parameter.

  3. Make state configurable params["state"] = provider.options.state || "abcd";

  4. Point in documentation that you use Space separated scopes.

Instagram authentication implementation

Hello,

I think a very useful feature to be included in the future would be to include the instagram authentication example.
I think it will be very useful in the future and will be gratefully appreciated.

Unable to login with the Microsoft provider

Which platform(s) does your issue occur on?

-Andorid

Please, provide the following version numbers that your issue occurs with:

  • CLI: 5.2.4
  • Cross-platform modules: 5.2.2
  • Runtime(s): 5.2.0
  • Plugin(s): "dependencies": {
    "@angular/animations": "~7.2.0",
    "@angular/common": "~7.2.0",
    "@angular/compiler": "~7.2.0",
    "@angular/core": "~7.2.0",
    "@angular/forms": "~7.2.0",
    "@angular/http": "~7.2.0",
    "@angular/platform-browser": "~7.2.0",
    "@angular/platform-browser-dynamic": "~7.2.0",
    "@angular/router": "~7.2.0",
    "nativescript-angular": "~7.2.1",
    "nativescript-oauth2": "^1.4.1",
    "nativescript-theme-core": "~1.0.4",
    "reflect-metadata": "~0.1.12",
    "rxjs": "~6.3.0",
    "tns-core-modules": "~5.2.0",
    "zone.js": "~0.8.26"
    },
    "devDependencies": {
    "@angular/compiler-cli": "~7.1.0",
    "@nativescript/schematics": "~0.5.0",
    "@ngtools/webpack": "~7.1.0",
    "nativescript-dev-typescript": "~0.8.0",
    "nativescript-dev-webpack": "~0.20.0"
    },

Please, tell us how to recreate the issue in as much detail as possible.

git clone https://github.com/alexziskind1/nativescript-oauth2.git

Modify demo-angular app\src\app.component.ts, line 19 to read: .tnsOauthLogin("microsoft")
Build and deploy to android device.
Hit the login button.
Sign in with a microsoft account. I used a live account.
The app will not proceed beyond the permissions acceptance screen. See screenshot.

I first tried in my own app with my own client id and callback urls, but I received the same issue. So I pulled the repo to try it with the demo app and it is repeatable there.

Screenshot_20190329-152335

Demo-VueJs Error

Hi Alex!
First thank you for this plugin. Bellow the following error I encountered.

Make sure to check the demo app(s) for sample usage

Yes and here the problem I encountered.

Make sure to check the existing issues in this repository

Yes

If the demo apps cannot help and there is no issue for your problem, tell us about it

Please, ensure your title is less than 63 characters long and starts with a capital
letter.

Upon checking your demo app, after npm install and command "tns run android --bundle" and error occured. Here's the screenshot of the error.
https://ibb.co/fUtN4f

Also I have a question: Why under demo-vue folder, I dont see the imported "auth-service" file.

var auth_service_1 = require("../auth-service");
Where is the file located?

Which platform(s) does your issue occur on?

  • iOS/Android/Both
  • iOS/Android versions
  • emulator or device. What type of device?
    Im using Windows 10

Please, provide the following version numbers that your issue occurs with:

  • CLI: (run tns --version to fetch it)
  • Cross-platform modules: (check the 'version' attribute in the
    node_modules/tns-core-modules/package.json file in your project)
  • Runtime(s): (look for the "tns-android" and "tns-ios" properties in the package.json file of your project)
  • Plugin(s): (look for the version numbers in the package.json file of your
    project and paste your dependencies and devDependencies here)

I dont add anything. All dependencies/devDep is the default one in your demo.

Please, tell us how to recreate the issue in as much detail as possible.

Describe the steps to reproduce it.
1.Download via zip
2. go to folder "demo-vue" then run "npm install" and "tns run android --bundle"

Is there any code involved?

  • provide a code example to recreate the problem
  • (EVEN BETTER) provide a .zip with application or refer to a repository with application where the problem is reproducible.
    No added code****

Unable to implement a custom provider, problem with TnsOaProviderType

Hi,

I am trying to implement a custom provider and I am stuck on extending the type TnsOaProviderType. I get a compilation error says:

Property 'providerType' in type 'TnsOaProviderMyProvider' is not assignable to the same property in base type 'TnsOaProvider'.
Type 'ProviderTypeMyProvider' is not assignable to type 'TnsOaProviderType'.
Type '"MyProvider"' is not assignable to type 'TnsOaProviderType'.

I tried the code in the documentation but it didn't work:
export declare type ProviderTypeMyProvider = "MyProvider";

I also tried this with no luck at all:
export declare type ProviderTypeMyProvider = TnsOaProviderType | "MyProvider";

What am I missing here please? I appreciate your help.
Regards,
Anas.

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.