Cannot read property 'responseType' of null
See original GitHub issueHello,
I have this error when I call the initImplicitFlow() method.
Error in initImplicitFlow TypeError: Cannot read property 'responseType' of null
at angular-oauth2-oidc.js:943
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:391)
at Object.onInvoke (core.js:17289)
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:390)
at Zone.push../node_modules/zone.js/dist/zone.js.Zone.run (zone.js:150)
at zone.js:889
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:423)
at Object.onInvokeTask (core.js:17280)
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:422)
at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:195)
It’s a new project for test this oidc library. Here my package.json
{
"name": "oauth2",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"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.1",
"@angular/platform-browser": "~7.2.0",
"@angular/platform-browser-dynamic": "~7.2.0",
"@angular/router": "~7.2.0",
"angular-oauth2-oidc": "^5.0.2",
"bootstrap": "^4.2.1",
"core-js": "^2.5.4",
"rxjs": "~6.3.3",
"tslib": "^1.9.0",
"zone.js": "~0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.12.0",
"@angular/cli": "~7.2.2",
"@angular/compiler-cli": "~7.2.0",
"@angular/language-service": "~7.2.0",
"@types/node": "~8.9.4",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"codelyzer": "~4.5.0",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~3.1.1",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.11.0",
"typescript": "~3.2.2"
}
}
And my AppComponent
title = 'oauth2';
constructor(private oAuthService: OAuthService) {
this.oAuthService.oidc = true;
this.oAuthService.issuer = 'http://localhost:20150/auth/realms/demo-oidc';
this.oAuthService.redirectUri = window.location.origin + '/index.html';
this.oAuthService.clientId = 'spa-client';
this.oAuthService.scope = 'openid profile email';
this.oAuthService.tokenValidationHandler = new JwksValidationHandler();
this.oAuthService.loadDiscoveryDocumentAndTryLogin()
.then(d => {
console.log('discovery and login OK', d);
})
.catch(err => console.log('discovery and login ERROR', err));
}
public login(): void {
this.oAuthService.initImplicitFlow();
}
public logout(): void {
this.oAuthService.logOut();
}
}
Thanks for your help 😃
Issue Analytics
- State:
- Created 5 years ago
- Comments:5
Top Results From Across the Web
angular - TypeError: Cannot read property 'nonceStateSeparator
The sign in function seems to work though, as it returns the tokens as parameters in the url in the application. My code:...
Read more >OAuthService - angular-oauth2-oidc
Service for logging in and logging out with OIDC and OAuth2. Supports implicit flow and password flow. Extends. AuthConfig. Index. Properties.
Read more >XMLHttpRequest.responseText - Web APIs | MDN
The read-only XMLHttpRequest property responseText returns the text received from a server following a request being sent.
Read more >cannot read properties of null (reading 'body') - You.com
Step 1: When the app runs first, the render is getting executed, at this moment, the value of this.state.post is null as shown...
Read more >HttpRequest - Angular
HttpParams; responseType?: "arraybuffer" | "blob" | "text" ... Property, Description. body: T | null, Read-Only. The request body, or null if one isn't...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi,
After some tests, your sample work ;p with the last version (5.0.2). And in my project, I have found that set configs like
this.oAuthService.issuer = 'xxxxx'
not work. The ‘config’ const file work well with Angular DI orthis.oAuthService.configure(config);
or like this :Here in oauth-service.ts, when I try to configure the library with
this.config
is nullSo I think that I must use
this.oAuthService.configure(config)
withnew AuthConfig()
object.Sorry for the late answer 😕 (UTC-10) Thanks for your help 😄
Looking back, I think we can close this issue as OP posted their solution, and some other issues and PRs handle the rest. Let us know if it should be reopened!