Matt Raible
If you using the Okta Angular SDK and its OktaAuthGuard
, it should redirect you back to the route you requested after authentication.
Matt Raible
If you using the Okta Angular SDK and its OktaAuthGuard
, it should redirect you back to the route you requested after authentication.
Neeraj
HI I am getting this error msg
Access to XMLHttpRequest at 'https://dev-369378.okta.com… from origin ‘http://localhost:4200’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.
Matt Raible
Log in to your Okta dashboard, go to API > Trusted Origins and add http://localhost:4200.
Neeraj
I had done that already
Neeraj
Can u pls guide me on this
Matt Raible
I’ve you’ve already added http://localhost:4200 as a trusted origin, I’m not sure how to help you. This usually solves it. I’d recommend emailing developers@okta.com to create a support ticket.
Harinath
If you are using Angular 9,
replace (in app.module.js)
import { MatToolbarModule,
MatMenuModule,
MatIconModule,
MatCardModule,
MatButtonModule,
MatTableModule,
MatDividerModule } from ‘@angular/material’;
with
import { MatToolbarModule } from ‘@angular/material/toolbar’;
import { MatMenuModule } from ‘@angular/material/menu’;
import { MatIconModule } from ‘@angular/material/icon’;
import { MatCardModule } from ‘@angular/material/card’;
import { MatButtonModule } from ‘@angular/material/button’;
import { MatTableModule } from ‘@angular/material/table’;
import { MatDividerModule } from ‘@angular/material/divider’;
Harinath
Check the LoginComponent and provide the baesURL properly as shown below:
export class LoginComponent implements OnInit {
widget = new OktaSignIn({
baseUrl: ‘https://dev-xxxxxx.okta.com’
});
H Guo
Looks like you are hard-coding client ID and issuer in the application code. Is there any security concern by doing that?
Matt Raible
No. You can think of a client ID like a license plate number. The issuer is like the state’s name on your license plate.
Matt Raible
Can you fork this tutorial’s repo and create a PR with the change you’re trying to make? That would help me better understand what you’re trying to do.
dennis602
Can we default this to the login widget without having to click the login link. Right now, the screen is blank until the Login button is clicked.
Matt Raible
You could change the default route so it always goes to /login
in src/app/app-routing.module.ts
. However, then you’d need to add logic to LoginComponent
so if the user is already logged in, it redirects them back to the HomeComponent
.
Ken Hadden
What are the minimum Okta services required to do OIDC in an angular app if I want to host the IDP on-premise?
Matt Raible
Hello Ken,
Okta used to be cloud-only. Then we added Okta Access Gateway for on-premise. You might have more luck asking this question on our developer forums.
Suraj Gupta
How can we add # in redirect url? I need # in redirect url for my Angular App
Matt Raible
You can’t. It’s not allowed by OAuth. See the core RFC6749 https://tools.ietf.org/html…
> The endpoint URI MUST NOT include a fragment component.
Pooja Dabholker
Can I integrate this method for app using angular 4?is it compatible
Pooja Dabholker
since my app is build on angular 4
Matt Raible
You can try. Let me know if it works! Honestly, I wouldn’t recommend using Angular 4 since it likely things have vastly improved since then.