sitefinitysteve / nativescript-auth0 Goto Github PK
View Code? Open in Web Editor NEWNativescript Auth0 https://auth0.com/ social authentication plugin
License: Other
Nativescript Auth0 https://auth0.com/ social authentication plugin
License: Other
I've been trying to add log out functionality to my app and I noticed it was still returning true for hasValidToken()
even after calling clearTokens()
Looking closer at the code I saw:
public clearTokens(): void{
appSetttings.remove(Auth0Lock._tokenKey);
};
but hasValidToken()
is checking this.credientials.accessToken
which isn't loaded from appsettings until refresh()
is called:
public refresh(): void{
if (appSetttings.hasKey(Auth0Lock._tokenKey)) {
var data = JSON.parse(appSetttings.getString(Auth0Lock._tokenKey));
this.credientials = {
accessToken: data.accessToken,
idToken: data.idToken,
refreshToken: data.refreshToken,
};
}
};
Which won't refresh because appSetttings.hasKey(Auth0Lock._tokenKey)
is false after calling clearTokens()
Is there a good way to log out?
If not I propose adding the following to clearTokens()
public clearTokens(): void{
appSetttings.remove(Auth0Lock._tokenKey);
this.credientials = { // should cause hasValidToken() to fail
accessToken: "",
idToken: "",
refreshToken: ""
};
};
Error after successful auth on Android.
Compiler complains about this.refresh() in auth0.js.
Check.
tns --version
to fetch it): 4.2.3node_modules/tns-core-modules/package.json
file in your project): 4.2.0"tns-android"
and "tns-ios"
properties in the package.json
file of your project) n/apackage.json
file of your"dependencies": {
"nativescript-theme-core": "^1.0.4",
"nativescript-vue": "^1.3.1",
"tns-core-modules": "4.2.0",
"vue-router": "^3.0.1",
"nativescript-auth0": "2.0.3",
"auth0-js": "^9.4.1",
"nativescript-vue-externals": "0.2.0"
},
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.4",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-env": "^1.6.1",
"copy-webpack-plugin": "^4.5.1",
"css-loader": "^0.28.11",
"extract-text-webpack-plugin": "^3.0.2",
"fs-extra": "^5.0.0",
"nativescript-vue-externals": "^0.2.0",
"nativescript-vue-loader": "^0.1.5",
"nativescript-vue-target": "^0.1.0",
"nativescript-vue-template-compiler": "^1.3.1",
"node-sass": "^4.7.2",
"ns-vue-loader": "^0.1.2",
"optimize-css-assets-webpack-plugin": "^3.2.0",
"rimraf": "^2.6.2",
"sass-loader": "^6.0.7",
"vue-template-compiler": "^2.5.16",
"webpack": "^3.11.0",
"webpack-synchronizable-shell-plugin": "0.0.7",
"winston-color": "^1.0.0"
}
I'm trying to use the default nativescript-vue template. After installing nativescript-auth0 with a clean vue template and following the directions from the README, I run into this error when running: npm run watch:android
// main.ts
import authService from './services/auth.service';
(new authService()).login();
// auth.service.js
export default class AuthService {
constructor() {
this.login = this.login.bind(this);
this.auth0 = new auth0(clientId, domain);
}
login() {
this.auth0.webAuthentication({
scope: 'openid offline_access'
}).then((res) => {
console.log('res', res);
}, (error) => {
console.log('error', error);
});
}
}
Android API 28 is all I've tested it on.
When using Android and we add the prompt
parameter to the webAuthencation
initializer and set it to none
, then we get an error with the callback URL. here is a screenshot from the Android Emulator. To be clear, this issue happens on a device as well.
This is happening in our source app, so I cloned a copy of the repo and the demo app behaves in the same way. This issue occurs regardless of whether or not you have logged in before and your credentials have been cached. Upon first running the app for the first time, the issue will occur and if you have logged in before, then the next time you go through the login process, then it will occur.
In the demo
folder, add the prompt
parameters to the webAuthentication
method in main-view-model.ts
file and set it to none
:
this.auth0.webAuthentication({
scope: 'openid offline_access',
parameters: {
prompt: 'none'
}
}).then((result) => {
this.message = JSON.stringify(result);
console.log(result);
}).catch((e: Error) => console.log(e, e.stack));
Hi,
I had the 1.2.7 version with the lock and it was great , i just wanted to use my custom login that i did on auth0.
So after i saw you did a 2.0 version with it i added it.
And then i see it's just redirecting me in a browser page..
I don't understand anymore what is your library helping ..
I could just do the same with a webview ..
I liked the idea that it's in my application himself , if it's on a browser that's not great for security and visually it's also not so great ..
Maybe i missed something if it's the case i'm sorry , i just try to understand.
Thank you for your job !
When I install this plugin on a fresh NX install, it complains about the version of Android needed.
FAILURE: Build failed with an exception.
Manifest merger failed : Attribute meta-data#android.support.VERSION@value value=(25.3.1) from [com.android.support:customtabs:25.3.1] AndroidManifest.xml:24:9-31
is also present at [com.android.support:design:26.0.0-alpha1] AndroidManifest.xml:27:9-38 value=(26.0.0-alpha1).
Suggestion: add 'tools:replace="android:value"' to element at AndroidManifest.xml:22:5-24:34 to override.
Is it possible to make it version agnostic or ^25?
platforms\android\build\intermediates\res\merged\F0F1\debug\values-v24\values-v24.xml:4: AAPT:
Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Colored'.
To reproduce:
tns create TestProject --ng
cd TestProject
tns run android
tns tns plugin add nativescript-auth0
AndroidManifest.xml
tns run android
I'm not pulling from npm, as I wanted source in my project. so maybe this is just from master?
Template parse errors:
JS: "let-" is only supported on template elements. ("
JS:
JS: <ListView [items]="items" class="list-group">
JS: <ng-template [ERROR ->]let-item="item">
JS: <Label [nsRouterLink]="['/item', item.id]" [text]="item.name"
JS: "): ItemsComponent@4:21
JS:
JS: Error: Template parse errors:
JS: "let-" is only supported on template elements. ("
JS:
JS: <ListView [items]="items" class="list-group">
JS: <ng-template [ERROR ->]let-item="item">
JS: <Label [nsRouterLink]="['/item', item.id]" [text]="item.name"
JS: "): ItemsComponent@4:21
JS: at SyntaxError.BaseError [as constructor] (file:///data/data/org.nativescript.auth0test/files/app/tns_modules/@angular/compiler/bundles/compiler.umd.js:1595:29)
JS: at new SyntaxError (file:///data/data/org.nativescript.auth0test/files/app/tns_modules/@angular/compiler/bundles/compiler.umd.js:1793:18)
JS: at TemplateParser.parse (file:///data/data/org.nativescript.auth0test/files/app/tns_modules/@angular/compiler/bundles/compiler.umd.js:11210:21)
JS: at JitCompiler._compileTemplate (file:///data/data/org.nativescript.auth0test/files/app/tns_modules/@angular/compiler/bundles/compiler.umd.js:27480:70)
JS: at file:///data/data/org.nativescript.auth0test/files/app/tns_modules/@angular/compiler/bundles/compiler.umd.js:27363:64
JS: at Set.forEach (native)
JS: at JitCompiler._compileComponents (file:///data/data/org.nativescript.auth0test/files/app/tns_modules/@angular/compiler/bundles/compiler.umd.js:27363:21)
JS: at createResult (file:///data/data/org.nativescript.auth0test/files/app/tns_modules/@angular/compiler/bundles/compiler.umd.js:27246:21)
JS: at ZoneDelegate.invoke (file:///data/data/org.nativescript.auth0test/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:190:28)
JS: at Zone.run (file:///data/data/org.nativescript.auth0test/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:83:43)
Can i use Auth0 Functions not Auth0Lock with this plugin ???
package.json file:
I should start by saying that I've succesfully managed get this entire authenication flow working for Android without any problems.
Now when I attempt it on iOS the following steps occur:
After this, I built the page such that there is a fail safe with an authenication call with a 'login' prompt. Now as expected, after the user clicks this it opens up a form for the user to fill in their credentials. After succesful authenication (Auth0 logs confirm the auth is succesful) (there also is a pop up that comes and vanishes really quick to save the password), then the authenication promise itself reports back as failing.
Now if the user exits the app (clears the app from the tray), and reopens it, the entire authenication flow suceeds without needed the user to enter their credentials - confirming that safari did indeed succesfully log the user in... After this the remainder of the app works - but I require the authenication process to work in an intuitive manner.
Why is the authenication flow not going as expected? Am I missing something?
My project is a nativescript-vue one, I'm attaching the main Master.vue component where the authenication takes place, as well as my main.js
Master.vue:
main.js:
Hi,
I am getting error when I do tns run ios --emulator
.Below are the error
^
/Users/nativescript/platforms/ios/Pods/Auth0/Auth0/WebAuth.swift:175:38: error: consecutive declarations on a line must be separated by ';'
@available(, deprecated, message: "use response([.token])")
^
;
/Users/nativescript/platforms/ios/Pods/Auth0/Auth0/WebAuth.swift:175:38: error: expected declaration
@available(, deprecated, message: "use response([.token])")
^
/Users/netwarmer/nativescript/platforms/ios/Pods/Auth0/Auth0/WebAuth.swift:202:29: error: unknown attribute 'escaping'
func start(_ callback: @escaping (Result) -> Void)
^
/Users/nativescript/platforms/ios/Pods/Auth0/Auth0/Auth0Error.swift:33:29: error: use of undeclared type 'Error'
public protocol Auth0Error: Error {
^~~~~
/Users/nativescript/platforms/ios/Pods/Auth0/Auth0/NSData+URLSafe.swift:25:18: error: use of undeclared type 'Data'
public extension Data {
^~~~
/Users/nativescript/platforms/ios/Pods/Auth0/Auth0/NSURL+Auth0.swift:25:18: error: use of undeclared type 'URL'
public extension URL {
^~~
/Users/nativescript/platforms/ios/Pods/Auth0/Auth0/NSURLComponents+OAuth2.swift:25:11: error: use of undeclared type 'URLComponents'
extension URLComponents {
^~~~~~~~~~~~~
/Users/nativescript/platforms/ios/Pods/Auth0/Auth0/AuthenticationError.swift:147:32: error: use of undeclared type 'CustomNSError'
extension AuthenticationError: CustomNSError {
^~~~~~~~~~~~~
** BUILD FAILED **
The following build commands failed:
CompileSwift normal x86_64 /Users/nativescript/platforms/ios/Pods/Auth0/Auth0/_ObjectiveAuthenticationAPI.swift
CompileSwift normal x86_64 /Users/nativescript/platforms/ios/Pods/Auth0/Auth0/_ObjectiveManagementAPI.swift
CompileSwift normal x86_64 /Users/nativescript/platforms/ios/Pods/Auth0/Auth0/_ObjectiveWebAuth.swift
CompileSwift normal x86_64
/Users/nativescript/platforms/ios/Pods/Auth0/Auth0/Auth0.swift
CompileSwift normal x86_64 /Users/nativescript/platforms/ios/Pods/Auth0/Auth0/Auth0Authentication.swift
CompileSwift normal x86_64 /Users/nativescript/platforms/ios/Pods/Auth0/Auth0/Auth0Error.swift
CompileSwift normal x86_64 /Users/nativescript/platforms/ios/Pods/Auth0/Auth0/Authentication.swift
CompileSwift normal x86_64 /Users/nativescript/platforms/ios/Pods/Auth0/Auth0/AuthenticationError.swift
CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler
Hi , thanks a lot for all your help.
In Android everything is working fine , but I have a problem in iOS.
I'm on the 1.2.7 version of your library ( I prefer this one , I don't want my user to be redirected to a browser)
I'm on NativeScript Angular version 4.1.2.
So i do with this template : https://github.com/sitefinitysteve/nativescript-auth0/tree/d2e40f4d5c60199072133c1c1330ed81f6d28b7d
But I have the error
" We're sorry , something went wrong when attempting to login".
My Packages are like that :
{
"description": "NativeScript Application",
"license": "SEE LICENSE IN <your-license-filename>",
"readme": "NativeScript Application",
"repository": "<fill-your-repository-here>",
"nativescript": {
"id": "org.nativescript.JarggonTranslatorApp",
"tns-android": {
"version": "4.1.3"
},
"tns-ios": {
"version": "4.1.1"
}
},
"dependencies": {
"@angular/animations": "~6.0.6",
"@angular/common": "~6.0.6",
"@angular/compiler": "~6.0.6",
"@angular/core": "~6.0.6",
"@angular/forms": "~6.0.6",
"@angular/http": "~6.0.6",
"@angular/platform-browser": "~6.0.6",
"@angular/platform-browser-dynamic": "~6.0.6",
"@angular/router": "~6.0.6",
"nativescript-angular": "~6.0.6",
"nativescript-auth0": "^1.2.7",
"nativescript-plugin-firebase": "^6.7.0",
"nativescript-theme-core": "~1.0.4",
"nativescript-ui-gauge": "^3.6.0",
"nativescript-webview-interface": "^1.4.2",
"reflect-metadata": "~0.1.10",
"rxjs": "~6.1.0",
"tns-core-modules": "4.1.1",
"zone.js": "~0.8.18"
},
"devDependencies": {
"@angular/compiler-cli": "~6.1.0-beta.3",
"@ngtools/webpack": "6.1.0-rc.0",
"babel-traverse": "6.4.5",
"babel-types": "6.4.5",
"babylon": "6.4.5",
"lazy": "1.0.11",
"nativescript-dev-typescript": "~0.7.0",
"nativescript-dev-webpack": "~0.14.0",
"typescript": "~2.7.2"
}
}
I added this at the end of the Info.plist :
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>None</string>
<key>CFBundleURLName</key>
<string>auth0</string>
<key>CFBundleURLSchemes</key>
<array>
<string>org.nativescript.JarggonTranslatorApp</string>
</array>
</dict>
</array>
I added a Auth0.plist at the same place of the Info with this inside :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ClientId</key>
<string>vHfWU8tWDEGTFosuqL9QnGG1RfsFh0T6</string>
<key>Domain</key>
<string>jarggon.eu.auth0.com</string>
</dict>
</plist>
My code in my component is like this :
if (!this.auth0Service.lock.hasValidToken()) {
this.auth0Service.lock.show().then(function (auth0res) {
console.log(auth0res);
that.auth0Service.lock.getUserInfo().then(user => {
that.http.post("https://us-central1-jarggon-66948.cloudfunctions.net/getToken",
{ userId: user.sub },
{ headers: new Headers({ 'Authorization': 'Bearer ' + auth0res.credentials.accessToken }) }
).subscribe((s) => {
firebase.login({
type: firebase.LoginType.CUSTOM,
customOptions: {
token: s.text()
}
});
}, (e) => { console.log('http error', e) });
});
}, function (error) {
console.log(error);
});
}
else {
this.router.navigate(['/logged'], { clearHistory: true });
}
But I don't think the problem is from there because it's working on android.
I puted the callback url like that :
org.nativescript.JarggonTranslatorApp://jarggon.eu.auth0.com/ios/org.nativescript.JarggonTranslatorApp/callback
I also tried :
https://jarggon.eu.auth0.com/ios/org.nativescript.JarggonTranslatorApp/callback
But doesn't work.
I puted all the Grant types .. I tried to put all the console.log I can but I don't have any error message , I also don't have any error in the auth0 logs ...
Trying to set an auth parameter.
This is what I'm trying to accomplish: https://auth0.com/docs/libraries/lock/v10/sending-authentication-parameters
My code:
var paramBuilder = com.auth0.android.authentication.ParameterBuilder.newBuilder();
var authenticationParameters = paramBuilder.set("state", 12345);
builder.withAuthenticationParameters(authenticationParameters);
The lock doesn't appear after this.
Currently, on the iOS application, not only do we have to use a browser-based hosted web page that makes us route away from our application to a login screen that doesn't have a native feel, but iOS also makes us accept a warning notification before being directed to the hosted login page ("" Wants to Use "auth0.com" to Sign In [Cancel/Continue]).
Is there some way to use a custom login where we pass through user-entered username and password to Auth0 without being directed away from the application? Or at least get rid of the iOS message making us hit "Continue" before being asked to login in the browser.
Hi.
I have got an error when trying to run demo project on iOS:
[!] Unable to satisfy the following requirements:
Lock (~> 2.0)
required byPodfile
Specs satisfying theLock (~> 2.0)
dependency were found, but they required a higher minimum deployment target.
The Vue Demo requires the Custom-App-Delegate script to be present. At the moment, this script is only on the main demo app.
Current Latest Version 6.0.2
App is copied from Demo Vue branch.
Was not able to find a similar issue.
I followed the Vue Demo branch. In my application, I am able to invoke the Auth0 login via the following code:
login () {
const auth0 = new Auth0('CLIENT_ID', 'DOMAIN');
auth0.webAuthentication({
scope: "openid offline_access"
}).then((result) => {
console.log('result', result)
})
}
When the Auth0 window opens, I enter valid credentials and proceeded. Afterwards, Safari just displays:
Safari cannot open the page because the address is invalid.
I check the logs on my Auth0 and it says Successful Login.
Followed steps as provided in the demo and notes.
Sample code to invoke the login page is provided above.
Error after installing and updating plist files
`tns run ios
Executing before-prepare hook from /Users/deBijenkorf/Apps/whattodo/hooks/before-prepare/nativescript-dev-typescript.js
Found peer TypeScript 2.1.6
Preparing project...
Successfully prepared plugin nativescript-angular for ios.
Successfully prepared plugin nativescript-intl for ios.
Successfully prepared plugin nativescript-auth0 for ios.
Successfully prepared plugin nativescript-iqkeyboardmanager for ios.
Successfully prepared plugin nativescript-social-share for ios.
Successfully prepared plugin nativescript-unit-test-runner for ios.
Successfully prepared plugin tns-core-modules for ios.
Successfully prepared plugin tns-core-modules-widgets for ios.
Installing pods...
Analyzing dependencies
[!] Unable to satisfy the following requirements:
Lock (~> 2.0)
required by Podfile
Specs satisfying the Lock (~> 2.0)
dependency were found, but they required a higher minimum deployment target.
Processing node_modules failed. Error: Command pod failed with exit code 1
Sending exception report (press Ctrl+C to stop).....`
Just checking to make sure I'm not doing something wrong, but when trying to run the Demo app you provided I get this after running tns install:
Could not install /Users/steve/Dropbox/Projects/Plugins/nativescript-auth0
which shows in package.json line 12:
"nativescript-auth0": "file:///Users/steve/Dropbox/Projects/Plugins/nativescript-auth0",
changing that to:
"nativescript-auth0": "^1.0.1",
fixes the issue.
Thanks!
Hi,
I found the issue for the plugin, which appears only when running application with plugin on real device. Application starts, but browser with auth0 is not opening, it freezes app and after a longer time it returns WebAuthException. It works perfectly for iOS.
I was not able to see any logs or errors, but maybe its because I dont know how to retrieve it.
This is reproducible for demo application present in repository (nativescript-core), when running on physical device (works well on simulator)
Demo application from repository
How does one pass other options into AuthLock instance? i want to use a custom unique scheme and not https, but there seems not to be a way to do that.
especially around app.module.ts setup and AOT
My authentication workflow is working as described in the example. After successful login, I get the following information:
{
"access_token":"*************************",
"token_type":"Bearer",
"id_token":"***************************************",
"refresh_token":"**************************************",
"expires_in":86400,
"expires_at":"2019-10-18T23:04:50.387Z"
}
As I am also using Auth0 to secure my backend services, I tried to pass the tokens I retrieved (access_token, id_token) but both of them are getting an unauthorized response from my backend.
Is there an additional step that I need to take to get the proper access token that I can use as Bearer authorization on my api call?
My code so far (NS-Vue):
login () {
let auth0 = new Auth0('*****', '*****.auth0.com')
auth0.webAuthentication({
scope: 'openid offline_access'
}).then((result) => {
let authenticationCredentials = result
let access_token = authenticationCredentials.access_token
let id_token = authenticationCredentials.id_token
// Using any token to an Auth0 Protected Backend API call is saying not authorized....
auth0.getUserInfo(access_token).then((userInfo) => {
// userInfo object is retrieved here properly...
console.log(JSON.stringify(userInfo))
})
})
}
The access_tokens retrieved allows me to:
This a call out to anyone who wishes to takeover maintenance of this library.
Starting in Jan 2020 the company I work for will move away from using NativeScript and as such I will no longer have the resources to maintain this library, with resources already starting to wind down.
If anyone is interested in taking over maintenance please reply here and get in touch with Steve (cc @sitefinitysteve) who is the project owner.
"dependencies": { "@vue/devtools": "^5.0.0-beta.3", "axios": "^0.18.0", "nativescript-auth0": "^2.1.0", "nativescript-clipboard": "^1.1.7", "nativescript-drop-down": "^4.0.1", "nativescript-floatingactionbutton": "^5.0.0", "nativescript-fonticon": "^2.0.0", "nativescript-iqkeyboardmanager": "^1.3.0", "nativescript-material-button": "^2.0.2", "nativescript-material-cardview": "^2.0.2", "nativescript-material-textfield": "^2.0.2", "nativescript-nested-scrollview": "^1.0.0", "nativescript-sentry": "^1.7.0", "nativescript-socket.io": "^0.9.0", "nativescript-theme-core": "^1.0.4", "nativescript-toast": "^1.4.6", "nativescript-ui-calendar": "^3.9.1", "nativescript-ui-gauge": "^3.8.0", "nativescript-unit-test-runner": "^0.3.4", "nativescript-videoplayer": "^4.2.1", "nativescript-vue": "^2.0.0", "nativescript-vue-devtools": "^1.1.0", "tns-core-modules": "^5.1.1", "vue-router": "^3.0.2", "vuex": "^3.0.1" }, "devDependencies": { "@babel/core": "~7.1.0", "@babel/preset-env": "~7.1.0", "babel-loader": "~8.0.0", "chai": "^4.2.0", "karma": "^3.1.4", "karma-chai": "^0.1.0", "karma-mocha": "^1.3.0", "karma-nativescript-launcher": "^0.4.0", "mocha": "^5.2.0", "nativescript-dev-webpack": "^0.17.0", "nativescript-vue-template-compiler": "^2.0.0", "node-sass": "~4.9.0", "vue-loader": "^15.4.0" },
Followed the guide at https://market.nativescript.org/plugins/nativescript-auth0, detail to detail.
On calling auth0.webAuthentication, nothing happens.
callOAuth() { this.auth0 = new Auth0('<client_id>', '<auth0 host>'); this.auth0.webAuthentication({ scope: 'openid offline_access profile email' }).then((res) => { console.log(res.idToken); }) },
"dependencies": {
"@vue/devtools": "^5.1.1",
"axios": "^0.19.0",
"nativescript-auth0": "^3.0.1",
"nativescript-socketio": "^3.3.1",
"nativescript-theme-core": "^2.0.21",
"nativescript-toasty": "^1.4.0",
"nativescript-vue": "^2.4.0",
"nativescript-vue-devtools": "^1.2.0",
"tns-core-modules": "^6.1.1",
"vue-axios": "^2.1.4"
},
"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": "^1.2.0",
"nativescript-vue-template-compiler": "^2.0.0",
"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"
}
I've correctly followed the configuration for the Android setup stipulated in your README file.
I'm using nativescript-vue and the below code is part of an authentication class export.
auth.service.js
import { Auth0 } from 'nativescript-auth0';
const CLIENTID = "imyourfavoriteclient"
const DOMAIN = "whatislyf.com"
export default class AuthService {
isLoggedIn() {
return ApplicationSettings.getBoolean('isLoggedIn', false);
}
login() {
return new Auth0(CLIENTID, DOMAIN)
.webAuthentication({
scope: 'openid offline_access',
parameters: {
prompt: 'login'
}
})
.then(x => console.log('LOG USER IN!'))
}
}
main.js
import Vue from 'nativescript-vue';
import AuthService from './services/auth.service';
import App from './screens/App';
import Login from './screens/Login.vue';
const authService = new AuthService();
new Vue({
render: h => h('frame', [h(authService.isLoggedIn() ? App : Login)])
}).$start();
The above code does not call a redirect for Android versions on 6.0 (Marshmellow) and lower on Android. Works perfectly fine on versions 7.0 (Nougat) and higher on Android by redirecting the user to google chrome for auth0 Login.
This is very problematic when I'm conducting a responsive design for old android versions and the app has auth0 as a bottleneck to enter the application. Please do reply asap because I'm nearing the publication date for my app at the Google Play Store.
Hi,
I am using this plugin to authenticate via Auth0 (nativescript + angular project), and so far I am able to succesfully login, but I am having problem with logout functionality.
Initially, when I call webAuthentication method I am redirected to browser, here I enter credentials and I am redirected back to application - that is good when I am doing so for the first time. But in case I logout (in my application - before token expires), and call webAuthentication method again, the browser pops out, authenticates me automatically and redirects to the application, which may not be a desired scenario every time (for example, if I want to log as another user).
I have noticed that if I clear cache of browser (android and iOS - outside of my application, in browser settings) - I am asked to reenter credentials, which is the behavior I want
Do anyone have idea how I can achieve this programatically?
Hello everyone,
To begin with , i'm quite new with this so excuse me if i forgot some informations and already thanks for your help.
First , my tns version is 4.1.2.
The version of tns-android is 4.1.3.
The version of nativescript-auth0 is 2.0.0.
I did as you saied , added to the Android Manifest :
<activity
android:name="com.auth0.android.provider.RedirectActivity"
tools:node="replace">
<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:host="jarggon.eu.auth0.com"
android:pathPrefix="/android/org.nativescript.JarggonTranslatorApp/callback"
android:scheme="https" />
</intent-filter>
</activity>
In my component i have :
lock.show().then((res) => {
console.log('success');
}, function (error) {
console.log(error);
});
With my instance of lock , everything is perfectly fine.
But when i'm running the app by " tns run android " i get this :
JS: Error: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.Context android.content.Context.getApplicationContext()' on a null object reference
JS: android.support.v4.content.LocalBroadcastManager.getInstance(LocalBroadcastManager.java:102)
JS: com.auth0.android.lock.Lock.initialize(Lock.java:144)
JS: com.auth0.android.lock.Lock.access$200(Lock.java:56)
JS: com.auth0.android.lock.Lock$Builder.build(Lock.java:236)
JS: com.tns.Runtime.callJSMethodNative(Native Method)
JS: com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1101)
JS: com.tns.Runtime.callJSMethodImpl(Runtime.java:983)
JS: com.tns.Runtime.callJSMethod(Runtime.java:970)
JS: com.tns.Runtime.callJSMethod(Runtime.java:954)
JS: com.tns.Runtime.callJSMethod(Runtime.java:946)
JS: com.tns.NativeScriptActivity.onCreate(NativeScriptActivity.java:18)
JS: android.app.Activity.performCreate(Activity.java:7041)
JS: android.app.Activity.performCreate(Activity.java:7032)
JS: android.app.Instrumentation.callActivityOnCre...
I know if from the console.log of the error in the lock.show() function , but i don't understand why..
I also tried to add a reference.d.ts file in the root and put in it :
/// <reference path="./node_modules/nativescript-auth0/typings/Auth0.ios.d.ts" />
/// <reference path="./node_modules/nativescript-auth0/typings/Lock.ios.d.ts" />
But i get something like 30 errors at runtime like :
node_modules/nativescript-auth0/typings/Auth0.ios.d.ts(2,43): error TS2552: Cannot find name 'NSObject'. Did you mean 'Object'?
node_modules/nativescript-auth0/typings/Auth0.ios.d.ts(8,42): error TS2304: Cannot find name 'NSURL'.
node_modules/nativescript-auth0/typings/Auth0.ios.d.ts(10,42): error TS2304: Cannot find name 'NSURL'.
node_modules/nativescript-auth0/typings/Auth0.ios.d.ts(10,58): error TS2304: Cannot find name 'NSURLSession'.
node_modules/nativescript-auth0/typings/Auth0.ios.d.ts(12,153): error TS2304: Cannot find name 'NSDictionary'.
node_modules/nativescript-auth0/typings/Auth0.ios.d.ts(12,195): error TS2304: Cannot find name 'NSError'.
node_modules/nativescript-auth0/typings/Auth0.ios.d.ts(12,208): error TS2304: Cannot find name 'NSDictionary'.
node_modules/nativescript-auth0/typings/Auth0.ios.d.ts(14,45): error TS2304: Cannot find name 'NSURL'.
node_modules/nativescript-auth0/typings/Auth0.ios.d.ts(16,52): error TS2304: Cannot find name 'NSURL'.
node_modules/nativescript-auth0/typings/Auth0.ios.d.ts(16,68): error TS2304: Cannot find name 'NSURLSession'.
node_modules/nativescript-auth0/typings/Auth0.ios.d.ts(18,118): error TS2304: Cannot find name 'NSDictionary'.
node_modules/nativescript-auth0/typings/Auth0.ios.d.ts(18,160): error TS2304: Cannot find name 'NSError'.
node_modules/nativescript-auth0/typings/Auth0.ios.d.ts(20,151): error TS2304: Cannot find name 'NSDictionary'.
node_modules/nativescript-auth0/typings/Auth0.ios.d.ts(20,193): error TS2304: Cannot find name 'NSError'.
node_modules/nativescript-auth0/typings/Auth0.ios.d.ts(22,93): error TS2304: Cannot find name 'NSError'.
I don't know what else i can do .. thanks for your help , if you need any information tell me ..
Is there any way to configure the "Redirect to" url (https://manage.auth0.com/#/emails) in the app?
I need to redirect to an app after the user verifies his/her email. I tried using the same callback url I use to authorize the user, but the app opens it doesn't receives any params.
Thanks!
asdasd
I can't install the last version of this repository, when i make tns plugin install nativescript-auth0 the installed version is 1.2.7
also i tried to make tns plugin install [email protected] and not work
please help ?
I'm getting this issue in a larger project I'm working in as well as the fork of this project I just created to validate if it was me or potentially the plugin. I'm using NS-Vue. I'm not sure if this is a NS-Vue specific issue or not, but I do have a suggested fix, which I'll show later.
As I mentioned, I forked this repo and have added a couple of views and moved some code around to try and simulate exactly what I'm seeing. As an aside and maybe this is a different issue, I couldn't get the demo-vue to run and bundle if the plugin was being referenced in src
. I had to install the plugin from npm to get it to run correctly.
Inside of main.ts
I'm attempting to intercept the logged in status of the user as the Vue instance is being setup. this will force to user to the Login screen if they aren't logged in.
import Vue from 'nativescript-vue';
import App from './components/App.vue';
import Login from './components/Login.vue';
const isLoggedIn = true;
new Vue({
render: (h) => h('frame', [h(isLoggedIn ? App : Login)]),
}).$start();
If I change isLoggedIn
to false, then the Login page will show, but the Universal Login will not open up. and I get the following error in the console:
Successfully synced application org.nativescript.auth0demo on device emulator-5554.
JS: '{NSVue (Vue: 2.5.17 | NSVue: 2.0.2)} -> CreateElement(NativeFrame)'
JS: '{NSVue (Vue: 2.5.17 | NSVue: 2.0.2)} -> CreateElement(NativePage)'
JS: '{NSVue (Vue: 2.5.17 | NSVue: 2.0.2)} -> CreateElement(NativeActionBar)'
JS: '{NSVue (Vue: 2.5.17 | NSVue: 2.0.2)} -> AppendChild(ElementNode(nativepage), ElementNode(nativeactionbar))'
JS: '{NSVue (Vue: 2.5.17 | NSVue: 2.0.2)} -> CreateElement(nativestacklayout)'
JS: '{NSVue (Vue: 2.5.17 | NSVue: 2.0.2)} -> CreateElement(nativelabel)'
JS: '{NSVue (Vue: 2.5.17 | NSVue: 2.0.2)} -> AppendChild(ElementNode(nativestacklayout), ElementNode(nativelabel))'
JS: '{NSVue (Vue: 2.5.17 | NSVue: 2.0.2)} -> AppendChild(ElementNode(nativepage), ElementNode(nativestacklayout))'
JS: '{NSVue (Vue: 2.5.17 | NSVue: 2.0.2)} -> AppendChild(ElementNode(nativeframe), ElementNode(nativepage))'
JS: [TypeError: Cannot read property 'getPackageManager' of undefined] 'TypeError: Cannot read property \'getPackageManager\' of undefined
JS: at WebAuthProvider.start (file:///data/data/org.nativescript.auth0demo/files/app/vendor.js:25220:58)
JS: at file:///data/data/org.nativescript.auth0demo/files/app/vendor.js:25996:17
JS: at new Promise (<anonymous>)
JS: at Auth0.webAuthentication (file:///data/data/org.nativescript.auth0demo/files/app/vendor.js:25994:12)
JS: at VueComponent.created (file:///data/data/org.nativescript.auth0demo/files/app/bundle.js:299:15)
JS: at callHook (file:///data/data/org.nativescript.auth0demo/files/app/vendor.js:31906:21)
JS: at VueComponent.Vue._init (file:///data/data/org.nativescript.auth0demo/files/app/vendor.js:39544:5)
JS: at new VueComponent (file:///data/data/org.nativescript.auth0demo/files/app/vendor.js:39719:12)
JS: at createComponentInstanceForVnode (file:///data/data/org.nativescript.auth0demo/files/app/vendor.js:39239:10)
JS: at init (file:///data/data/org.nativescript.a...
In tracing down where the error is coming from, The exception is being thrown from here, but it's really generated further upstream from here
For whatever reason, at this point in the lifecycle, application.activity.foregroundActivity
is undefined. There is some discussion here about this, but I'm not knowledgeable enough to know if it's relevant or not.
However, I do know that if I change foregroundActivity
to startActivity
, then things work just fine without any issues.
"dependencies": {
"@vue/devtools": "5.0.0-beta.3",
"nativescript-auth0": "^2.1.0",
"nativescript-socket.io": "^0.9.0",
"nativescript-toast": "^1.4.6",
"nativescript-vue": "^2.0.0",
"nativescript-vue-devtools": "^1.0.0",
"tns-core-modules": "^5.0.2"
},
"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.0",
"nativescript-worker-loader": "~0.9.0",
"node-sass": "^4.9.2",
"sass-loader": "^7.1.0",
"terser-webpack-plugin": "^1.1.0",
"tns-platform-declarations": "^5.1.2",
"typescript": "^3.2.4",
"vue": "^2.5.22",
"vue-loader": "^15.2.6",
"webpack": "^4.16.4",
"webpack-bundle-analyzer": "~2.13.1",
"webpack-cli": "^3.1.0"
}
Check my fork and run the demo-vue project. You can leave the isLoggedIn
variable to true for the first run just to validate you can navigate to the About
view as well as manually navigate to the Login
vue and have the Universal Login show up.
Once you change isLoggedIn
to false and save, then on the reload it will try and redirect to Login.vue
and will successfully do so, but the Universal Login will never appear.
There is some changes in new version of Lock for Android.
Now it needs to add the Manifest Placeholders for the Auth0 Domain and the Auth0 Scheme properties in build.gradle file and there is no need to define an intent-filter inside the LockActivity.
But now with this changes callback is not handled automatically with the nativescript application.
Hot module reload does not work with this plugin, because the compiled version misses one java class RedirectActivity
. If I compile without the --hmr
flag, RedirectActivity
will be created in the Android Java output.
My guess is, there is something wrong with the tns or webpack config.
"dependencies": {
"@angular/animations": "~6.1.0",
"@angular/common": "~6.1.0",
"@angular/compiler": "~6.1.0",
"@angular/core": "~6.1.0",
"@angular/forms": "~6.1.0",
"@angular/http": "~6.1.0",
"@angular/platform-browser": "~6.1.0",
"@angular/platform-browser-dynamic": "~6.1.0",
"@angular/router": "~6.1.0",
"@ngx-translate/core": "^11.0.0",
"nativescript-angular": "^6.2.0",
"nativescript-auth0": "^2.1.0",
"nativescript-localstorage": "^2.0.0",
"nativescript-texttospeech": "^2.0.2",
"nativescript-theme-core": "~1.0.4",
"nativescript-ui-sidedrawer": "~4.3.0",
"ngx-bootstrap": "^3.1.1",
"reflect-metadata": "~0.1.10",
"rxjs": "^6.0.0",
"tns-core-modules": "^5.0.5",
"zone.js": "^0.8.26"
},
"devDependencies": {
"@angular/compiler-cli": "~6.1.0",
"@nativescript/schematics": "~0.3.0",
"@ngtools/webpack": "~6.2.0",
"codelyzer": "~4.3.0",
"nativescript-dev-sass": "~1.6.0",
"nativescript-dev-typescript": "~0.7.0",
"nativescript-dev-webpack": "^0.17.0",
"simpl-marengo-icons": "^2.6.0",
"tslint": "~5.11.0",
"typescript": "~2.7.2"
}
Hi. When I'm trying to run the Demo app on iOS I get this error:
file:///app/login.js:22:20: ReferenceError: Can't find variable: A0Lock
.
Steps to reproduce:
platform :ios, '9.0'
to .../nativescript-auth0-master/demo/platforms/ios/Podfile"nativescript-auth0": "file:..",
in package.json line 12:tns plugin add nativescript-auth0
tns run ios
Simulator device: iPhone 6 iOS 10.3
TypeScript 2.3.2
lock.show() generates this error on android. Any idea what I'm missing?
my code
lock.show().then((res) => {
console.log('login success');
}, function (error) {
console.log(error);
});
error
An uncaught Exception occurred on "OkHttp Dispatcher" thread.
com.google.gson.JsonParseException: Missing required attribute callback
at com.auth0.android.lock.internal.configuration.GsonDeserializer.requiredValue(GsonDeserializer.java:40)
at com.auth0.android.lock.internal.configuration.ApplicationDeserializer.deserialize(ApplicationDeserializer.java:51)
at com.auth0.android.lock.internal.configuration.ApplicationDeserializer.deserialize(ApplicationDeserializer.java:40)
at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:69)
at com.google.gson.Gson.fromJson(Gson.java:887)
at com.google.gson.Gson.fromJson(Gson.java:852)
at com.google.gson.Gson.fromJson(Gson.java:801)
at com.auth0.android.lock.internal.configuration.ApplicationFetcher.parseJSONP(ApplicationFetcher.java:132)
at com.auth0.android.lock.internal.configuration.ApplicationFetcher.access$100(ApplicationFetcher.java:51)
at com.auth0.android.lock.internal.configuration.ApplicationFetcher$1.onResponse(ApplicationFetcher```
Need to prep and release version 2.0.0 to npm.
@sitefinitysteve, how would you like to do this?
I don't think I have access to publish to npm for this library.
when i try to use this the console dumps
ReferenceError: Can't find variable: A0Lock — auth0.js:14
after i do this.lock.show()
iOS shows an alert before directing user to auth0 login page. I learned that legacy authentication does not prompt an alert. Do you plan to implement useLegacyAuthentication() function in the SafariWebAuth class? Currently it just sets a boolean property but that property is not used anywhere.
The test if iOS 11 is available in SafariWebAuth silently fails if the iOS version received by device.osVersion contains a patch level.
Number(device.osVersion) >= 11.0 && this.authenticationSession
e.g. Number('11.2.2') results in NaN. Therefore the conditions evaluates to false and the legacy authentication is used.
I am trying to add calendar sync capability to my application, and I'd like to do this by using the Google Social login provided by Auth0.
The main problem I am having is with obtaining the Google refresh token, which should be within the user.identities[0].access_token when looking at a user's profile called from Auth0 User Management API (this is highlighted here: https://auth0.com/docs/connections/calling-an-external-idp-api#step-3-extract-the-idp-access-token).
Now to be able to succesfully to do this, the docs mention you MUST include access type = 'offline'
when calling the /authorize endpoint (as mentioned here: https://auth0.com/docs/tokens/overview-idp-access-tokens). I haven't been able to do this properly through the nativescript app, thus not able to get the refresh token from the user profile.
My /authorize section of the code looks like this...
auth0.webAuthentication({
scope: 'openid offline_access email profile',
parameters: {
"prompt": type
},
scheme: 'com.emit.app',
audience: 'https://emitapp.co.uk/api'
}).then((result) => { ....
Now I've tried adding parameters in all over the place (one at a time when testing) similar to this...
auth0.webAuthentication({
scope: 'openid offline_access email profile',
parameters: {
"prompt": type,
'access_type': 'offline',
'accessType': 'offline',
'access type': 'offline'
},
scheme: 'com.emit.app',
audience: 'https://emitapp.co.uk/api'
access_type: 'offline'
}).then((result) => {
The even wierder thing is that even if the user logs in on the webapp (there I am able to flow working to get the refresh token), when they then log onto the phone app the refresh token gets either 'deleted' or 'hidden' and since google doesn't reissue the token, I'm never able to obtain it again. I've resorted forcing my users to log in on my webapp and storing the refresh token on the server side. I'd really appreciate it if I could get the users who login on the Nativescript App showing the Google refresh token in their profile from Auth0 since I'm not a huge fan of storing them on my server vs Auth0's servers.
I've tried looking into people with similar problems as follows (unfortunatly no success, since most I assume are for webapps and not native code):
https://community.auth0.com/t/store-and-retrieve-google-refresh-token/28973
https://community.auth0.com/t/need-help-with-fetching-refresh-token-from-google-social-login/11699
https://community.auth0.com/t/cant-get-google-refresh-token-using-auth0-js/11756
We are able to successfully login, redirect back to the app and store the refreshToken
via nativescript-secure-storage
. However, when we need to update the accessToken
via the renewCredentials
method, we are unable to do so.
For Android, we see this in the console:
JS: [Vue warn]: Error in v-on handler (Promise/async): "Error: An error occurred when trying to authenticate with the server."
For IOS, we see this in the console:
[Vue warn]: Error in v-on handler (Promise/async): "Error: {"error":"access_denied","error_description":"Cannot read property 'redirect_uri' of undefined"}"
In the Auth0 Dashboard logs we are getting failures at the renewal. They are basically the same as the IOS error:
Occurred: 2 minutes ago at 2019-10-28 19:05:35.043 UTC
Type: Failed Exchange
Description: Cannot read property 'redirect_uri' of undefined
I can take the demo-vue
project and replace the domain
and the bundle_identifier
strings throughout with our values and that's when the issue starts.
If I change the app in the Auth0 backend (app -> Advanced Settings -> OAuth tab) to NOT be OIDC compliant then I can successfully use the refreshCredentials
method and update the accessToken
. So, I think the issue is something related to the request coming in not being OIDC compliant and Auth0's API service is rejecting the request.
A few docs questions.
In the android section it says "Requires your references.d.ts file to have android pointing to", it sems like there was a missing part to this instruction?
In the example code, there is this:
import { Auth0Lock } from "nativescript-auth0";
Should that be:
import { Auth0 } from "nativescript-auth0";
given the code that follows after that?
trying to get the plugin to my ios project working, not sure what i am doing wrong, i can't get past
file:///app/app.js:22:28: JS ERROR TypeError: auth0.initalize is not a function. (In 'auth0.initalize()', 'auth0.initalize' is undefined)
When persisting an UserInfo
object wrapped inside a different object to local or secure storage, the following keys are not being read back correctly from storage:
var profileURL = json["profile"];
var pictureURL = json["picture"];
var websiteURL = json["website"];
The wrapper object might look like this:
{
id: string,
userInfo: UserInfo
}
The wrapper object is being transformed to JSON by calling JSON.stringify()
. Therefore the userInfo
object is not being transformed by using toJSON
. This means the three properties as seen above are not being transformed from JWT standard names profile
, picture
and website
to the nativescript-auth0
names profileURL
, pictureURL
, websiteURL
and vice versa. The data is being lost on reading from storage and writing to storage again.
How to persist UserInfo
to storage inside a wrapper object without data loss and without saving UserInfo
on its own?
"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",
"kinvey-nativescript-sdk": "4.2.1",
"nativescript-angular": "^8.0.2",
"nativescript-auth0": "^2.1.2",
"nativescript-barcodescanner": "^3.2.1",
"nativescript-local-notifications": "^4.0.0",
"nativescript-plugin-firebase": "^9.0.3",
"nativescript-secure-storage": "^2.5.0",
"nativescript-theme-core": "~1.0.4",
"reflect-metadata": "~0.1.12",
"rxjs": "^6.3.3",
"subsink": "^1.0.0",
"tns-core-modules": "6.0.1",
"zone.js": "^0.9.1"
},
"devDependencies": {
"@angular/compiler-cli": "~8.0.0",
"@ngtools/webpack": "~8.0.0",
"nativescript-dev-webpack": "1.0.1",
"tns-platform-declarations": "6.0.1",
"node-sass": "4.12.0",
"typescript": "~3.4.5"
}
auth0
this.auth0.webAuthentication(…)
and save the credentialsthis.credentials.accessToken
to getUserInfo
and save the userInfo
wrapped inside of a different objectJSON.stringify()
JSON.parse()
After initializing the auth0
object as described in the docs and successfully completing webAuthentication
, the method getUserInfo
returns an undefined UserInfo
object. Some properties of this (allegedly) undefined UserInfo
are not undefined and accessible by property accessors dot (userInfo.sub
) or bracket (userInfo['sub'])
notation. Despite properties of the object being accessible, the object is interpreted as being undefined during runtime.
I tried:
promise.then
and the ES6 await
syntaxUserInfo
object with the UserInfo.initWithJson
methodUserInfo
object and adding the keys manuallyHow can a JavaScript object be undefined although some of its properties are defined?
See code example for more context.
"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",
"kinvey-nativescript-sdk": "4.2.1",
"nativescript-angular": "^8.0.2",
"nativescript-auth0": "^2.1.2",
"nativescript-barcodescanner": "^3.2.1",
"nativescript-local-notifications": "^4.0.0",
"nativescript-plugin-firebase": "^9.0.3",
"nativescript-secure-storage": "^2.5.0",
"nativescript-theme-core": "~1.0.4",
"reflect-metadata": "~0.1.12",
"rxjs": "^6.3.3",
"subsink": "^1.0.0",
"tns-core-modules": "6.0.1",
"zone.js": "^0.9.1"
},
"devDependencies": {
"@angular/compiler-cli": "~8.0.0",
"@ngtools/webpack": "~8.0.0",
"nativescript-dev-webpack": "1.0.1",
"tns-platform-declarations": "6.0.1",
"node-sass": "4.12.0",
"typescript": "~3.4.5"
}
auth0
this.auth0.webAuthentication(…)
and save the credentials
this.credentials.accessToken
to getUserInfo
and save the userInfo
this.userInfo
e.g. by printing to console console.log(this.userInfo)
Iterating over the keys of the returned user info and constructing a new element with its values where applicable:
const accessToken = await this.getAccessToken();
const userInfoRaw = await this.auth0.getUserInfo(accessToken); // this returns undefined although some object properties are accessible
const userInfo = <UserInfo>{};
for (const key in userInfoRaw) {
if (userInfoRaw.hasOwnProperty(key)) {
userInfo[key] = userInfoRaw[key];
}
}
https://play.nativescript.org/?template=play-ng&id=y1V4WU&v=3
I'm working in Angular and got things to work in iOS. When running in Android I get this: "Aw snap! Something went wrong while displaying this webpage."
I played around some with data element in the manifest.xml:
<data android:host="lubetech.auth0.com" android:pathPrefix="/android/lubetech.nativescript.shop/callback" android:scheme="https" />
I checked to make sure that this was in the callback.
Just running in an emulator... Nexus S-- Api 28 (Pie)
CLI: 5.1.1
TNS Modules: 5.1.0
TNS Android: 5.1.0
TNS iOS: 5.1.1
Plugins:
"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-theme-core": "~1.0.4",
"nativescript-ui-sidedrawer": "~5.1.0",
"nativescript-auth0": "^2.1.0",
"reflect-metadata": "~0.1.12",
"rxjs": "~6.3.0",
"tns-core-modules": "~5.1.0",
"zone.js": "~0.8.26"
},
"devDependencies": {
"@angular/compiler-cli": "~7.1.0",
"@nativescript/schematics": "~0.5.0",
"@ngtools/webpack": "~7.1.0",
"codelyzer": "~4.5.0",
"nativescript-dev-sass": "~1.6.0",
"nativescript-dev-typescript": "~0.7.0",
"nativescript-dev-webpack": "~0.19.0",
"tslint": "~5.11.0",
"npx": "10.2.0"
}
To re-create: Added a login component with a button and a tap event.
(login.component.html)
<Button text="Login" (tap)="onTap()">
(login.component.ts)
onTap() {
this.authenticationService.handleAuth0();
}
(authentication.service.ts)
import { Injectable } from '@angular/core';
import { Auth0, Credentials } from 'nativescript-auth0';
@Injectable({
providedIn: 'root'
})
export class AuthenticationService {
message = '';
requestedScopes =
'openid profile email ship-to administrate:all price:part place:order impersonate:all-ship-tos view:cost-price';
accessToken = '';
private auth0: Auth0;
constructor() {
this.auth0 = new Auth0('OtqkvtGzMJjEQfThhWdg65QUYU8QbK8x', 'lubetech.auth0.com');
}
handleAuth0() {
this.auth0
.webAuthentication({
scope: this.requestedScopes
})
.then((result) => {
this.getUserFromToken(result);
console.log(result);
})
.catch((e: Error) => console.log(e, e.stack));
}
getUserFromToken(auth0result: Credentials) {
this.message = JSON.stringify(auth0result);
this.accessToken = auth0result.accessToken;
this.auth0.getUserInfo(this.accessToken).then((userInfo) => {
this.message += userInfo;
});
}
}
Sending the zip along with this...
lubetech-shop-ns-ng.zip
The first 10 connections work fine, before a error occur: Cannot get ....../callback, what could be?
I can't get it to run with out tons of build errors on lollipop
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.