okta / samples-js-angular

samples-js-angular
https://github.com/okta/samples-js-angular
Other
73 stars 149 forks source link

Uncaught (in promise): OAuthError: User is not assigned to the client application #18

Closed laharshah closed 4 years ago

laharshah commented 6 years ago

I am using the OKta hosted login.

How do I catch the error on 'implicit/callback' route. When the unassinged user(User - not assigned people list for the application) try to login, it redirects to the blank page: "implicit/callback" with the following error in console.

core.js:1601 ERROR Error: Uncaught (in promise): OAuthError: User is not assigned to the client application. Error at Object../node_modules/@okta/okta-auth-js/lib/errors/OAuthError.js (OAuthError.js:20) at webpack_require__ (bootstrap:81) at Object../node_modules/@okta/okta-auth-js/lib/token.js (token.js:21) at webpack_require (bootstrap:81) at Object../node_modules/@okta/okta-auth-js/lib/clientBuilder.js (clientBuilder.js:23) at __webpack_require (bootstrap:81) at Object../node_modules/@okta/okta-auth-js/reqwest/index.js (index.js:15) at webpack_require__ (bootstrap:81) at Object../node_modules/@okta/okta-auth-js/lib/index.js (index.js:15) at webpack_require (bootstrap:81) at Object../node_modules/@okta/okta-auth-js/lib/errors/OAuthError.js (OAuthError.js:20) at __webpack_require (bootstrap:81) at Object../node_modules/@okta/okta-auth-js/lib/token.js (token.js:21) at webpack_require__ (bootstrap:81) at Object../node_modules/@okta/okta-auth-js/lib/clientBuilder.js (clientBuilder.js:23) at webpack_require (bootstrap:81) at Object../node_modules/@okta/okta-auth-js/reqwest/index.js (index.js:15) at __webpack_require (bootstrap:81) at Object../node_modules/@okta/okta-auth-js/lib/index.js (index.js:15) at __webpack_require__ (bootstrap:81) at resolvePromise (zone.js:783) at zone.js:709 at rejected (okta.service.js:24) at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:391) at Object.onInvoke (core.js:4071) 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:141) at zone.js:831 at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:424) at Object.onInvokeTask (core.js:4062)

mishrath commented 6 years ago

any update on this issue?

andrewf414 commented 5 years ago

I've got the same problem. It's not a huge deal in that they can't login, so fine. But it would be nice for us to be able to catch the error, so we can redirect to a failed auth page

subbu95 commented 5 years ago

i have same problem, created a rule for SPA application in okta for allowing only specific groups to access the application. When a user not present in groups tries to login this issue is creeping up in my client side application. Please try to resolve this

subbu95 commented 5 years ago

How to catch this error???/

aarongranick-okta commented 5 years ago

https://github.com/okta/okta-oidc-js/blob/master/packages/okta-angular/src/okta/components/callback.component.ts

As you can see the implicit callback component is very simple, containing only a single call to okta.handleAuthentication() The error you are trying to catch is most likely thrown from this method.

I recommend replacing the component handling for the /implicit/callback route from the Okta provided component to one of your own, which wraps okta.handleAuthentication() in a try { ... } catch (e) { then you should be able to handle the error and display a message / link to the user

Tymmoty commented 4 years ago

https://github.com/okta/okta-oidc-js/blob/master/packages/okta-angular/src/okta/components/callback.component.ts

As you can see the implicit callback component is very simple, containing only a single call to okta.handleAuthentication() The error you are trying to catch is most likely thrown from this method.

I recommend replacing the component handling for the /implicit/callback route from the Okta provided component to one of your own, which wraps okta.handleAuthentication() in a try { ... } catch (e) { then you should be able to handle the error and display a message / link to the user

Not working in a try catch block, but okta.handleAuthentication() is a promise so you can use okta.handleAuthentication().catch((err) => ...);

swiftone commented 4 years ago

Closing this issue: handling a rejected promise from .handleAuthentication() should cover the cases listed (https://github.com/okta/okta-oidc-js/tree/master/packages/okta-angular#oktaauthhandleauthentication)

If anyone continues to have a problem feel free to open a new issue with details and reference this issue.

jcardoz commented 1 year ago

Updated link as the SDK was moved.

https://github.com/okta/okta-angular/blob/master/lib/src/okta/components/callback.component.ts