angular-oauth2 | AngularJS OAuth2 | OAuth library
kandi X-RAY | angular-oauth2 Summary
kandi X-RAY | angular-oauth2 Summary
AngularJS OAuth2
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of angular-oauth2
angular-oauth2 Key Features
angular-oauth2 Examples and Code Snippets
Community Discussions
Trending Discussions on angular-oauth2
QUESTION
Been getting this error when running 'ng build' on my Angular 12.0.2 project
...ANSWER
Answered 2021-Jun-02 at 17:41We figured it out. As you can see in our packages.json
, we have a dependency on webpack
. It seems angular-devkit/build-angular
does as well. We believe this created the known issue of multiple webpacks colliding and causing issues. Removing our dependency on webpack
fixed the issue.
QUESTION
Since this turned out longer than expected here's a tl;dr:
My Angular application is not sending the bearer token it receives from Azure AD to the API and thus the API returns a 401 response. The setup is based on a blog post explanation for how to implement it. The sample application mentioned in the blog post works with my Azure AD setup and correctly provides the token on API calls.
Long version:
I'm working on a relatively simple Angular based front-end with a Spring Boot back-end. Front-end and back-end communicate via a REST API. The application is deployed on Azure Spring Cloud. For user Authentication the application requests and receives a bearer token from Azure AD. It should then transmit this token with each REST request to the API.
I followed this blog post to setup the necessary changes. Azure AD does deliver a valid JWT token.
My problem is, that the token is not passed on to the back-end in the REST calls and thus authentication fails and a 401 status is returned.
Here are the relevant configurations I made on the front-end side (based on the descriptions in the blog post linked):
app.module.ts
...ANSWER
Answered 2021-Jun-01 at 09:07OP here. As it turns out the problem was caused because the "X-Frame-Options" response header was set to "DENY". This header if set to "DENY" blocks invisible frames from being opened. The implementation uses an iFrame for the silent redirect during the authentication process and this crucial part was blocked.
To solve the issue I changed it to "SAME ORIGIN" in the back-end configurations
QUESTION
I'm using OAuth 2.0 to retrieve a Token for my User in my Angular Application. I use the popular lib angular-oauth2-oidc
for handling the OAuth Flow. So in my AppComponent I set up the oAuthService from angular-oauth2-oidc
and then initiate the oAuth Flow in my Login Component by calling initCodeFlow()
. The User is redirected to enter his credentials and afterwards he get's redirected to me and I recieve the token in the AppComponent and put it as next token into my DataService TokenSubject.
But now I want to make an API call with that token in the header in my MainPageComponent. So I subscribe in my MainPage to the TokenSubject and when I recieve the Token the code in the subscribe block get's executed.
But what if the token get's send to me quicker than the main page builds up? Then I'm not yet subscribed to the TokenSubject in the Main Page when the next Token value is emitted by the AppComponent. I'm not sure, but my main page sometimes did't open up and I think this is probably the reason.
What's the best way to make sure that the Main Page is subscribed to the TokenSubject, before I emit the TokenSubject?
My AppComponent
:
ANSWER
Answered 2021-Apr-26 at 11:29In short: you can't ensure it with Subject
.
You could use the RxJS ReplaySubject
instead. It's a variant of the more general Subject
you're using. However it can "hold/buffer" specific number of previous emissions and emit to future subscribers immediately upon subscription. In your case you could use buffer 1. It'll hold and emit the last pushed value pushed to it.
QUESTION
I am using angular-oauth2-oidc
in my project.
The Openid (identity) provider uses self signed certificate. The Identity provider is not in our control.
When we configure the identity url and try login from angular we always get an error.
ANSWER
Answered 2021-Apr-07 at 06:31What you can do is to make your windows machine to trust the self-signed certificate. But this will only be on your machine.
QUESTION
I went through several questions like 1 , 2 but I don't know how to make my app work.
Problem: When I sign in 1st time, I do not get Bearer token
and hence my SettingConfigService
fails with 401
, if I refresh the page, I get the token from this.oauth.getAccessToken()
because now the token is in localstorage
.
I am using oauth lib for login. Here is the modules and libs I have created.
App.module
...ANSWER
Answered 2021-Mar-26 at 18:38You need to follow the proper sequence to load config with the token. try:
app.module
QUESTION
I am attempting to integrate the angular-oauth2-oidc library with Auth0 and Github. Feel free to keep in mind I have selected all scopes(just to be safe), from the Auth0/Github UI side of things.
Using Latest FeaturesI am using the latest features that angular-oauth2-oidc has to offer.
- For instance, I am using code flow i.e.:
ANSWER
Answered 2021-Mar-24 at 19:49Just to answer my own question. This is a non-frontend-related error. Auth0 intentionally only allows the front end to have limited scopes: https://auth0.com/docs/tokens/management-api-access-tokens/get-management-api-tokens-for-single-page-applications
^ If using Auth0, the only way to get these scopes is to wrap your own API, with the secret client id behind the scenes. This is not a front end related issue. Then depending on permissions granted to backend API, you might be able to grab custom scopes via the backend.
QUESTION
I'm using angular-oauth2-oidc
's Code Flow in an Angular application. It's working all good, however I cannot read the user claims.
I tried using this.oAuthService.getIdToken()
, this.oAuthService.getAccessToken()
, this.oauthService.getUserInfo()
but I don't seem to get any valid JWT that can be decoded using regular methods.
In my backend API (.NET Core) I use the access_token
to query the TokenIntrospection endpoint and I can see all the claims properly.
Relevant info:
...ANSWER
Answered 2021-Mar-05 at 17:36There is a getIdentityClaims method that will give you id_token claims as an object. First though you need to check the HTTP requests to verify that an id_token is actually being returned, and that it contains the claims you expect.
CLAIMS ISSUING TO TOKENS
In an Authorization Server you can specify where claims are issued to and it is very standard to issue different claims to the two tokens:
- In your case an ID token is for use by a UI client and may contain details such as a name for display
- An access token is issued for use by an API client and might contain a role or user id used for authorization.
To better understand this concept, see the Claims Mapper concept used by the Curity Identity Server.
I suspect in your case the system is not configured to (or does not support) issuing some claims to the id token.
MY PREFERENCE
I actually think you are on the right track with your access token handling. Another way for a UI to get user info is to send the access token to its API, at a path such as /api/userinfo/current, and the API can then return a JSON object containing:
- Claims from the access token
- Any other domain specific data that may be useful to the UI
This design has the following benefits:
- Extensibility: it is easy to add extra data to the API payload, which may have nothing to do with OAuth
- Privacy: adding too much user data to an id_token is often not recommended, since it is then available in a viewable JWT which lasts for an entire user session
QUESTION
I want to use the code flow with PKCE in my Angular SPA and for convenience I use this library: angular-oauth2-oidc
If you click on the link, it says that with this configuration you will use the code flow with PKCE:
...ANSWER
Answered 2021-Feb-08 at 20:12I'm pretty certain it does - the way to be sure is to trace the network messages and look for code_challenge and code_challenge_method parameters in the authorization redirect. See steps 4 and 8 of my OAuth SPA Messages Page for how this should look.
QUESTION
My Authorization Client: Angular, Resource Server: Java Spring Boot, Authorization Server: Azure Active Directory
I am using oAuth2 to login via Angular via the PKCE Authorization Flow and then pass the token to the back end. I am able to access the token in my back end via the Authorization Beaer Header, but when I go to use that token to access Microsoft Graph API, I am getting an Invalid token exception.
com.microsoft.graph.http.GraphServiceException: Error code: InvalidAuthenticationToken Error message: CompactToken parsing failed with error code: 80049217
I am not sure why it is causing this error, because its valid and I can verify via https://jwt.io/ and access my other protected api in postman with the token.
AuthProvider.java
...ANSWER
Answered 2020-Dec-16 at 02:12An access token can only be for one resource. I can see that you configure scope: 'openid api://{appid}/app'
in your Angular Setup. It means the access token is for this resource api://{appid}/app
rather than Microsoft Graph https://graph.microsoft.com
. That is why you got the InvalidAuthenticationToken Error.
So if you want to call Microsoft Graph in your backend API, you need to consider OAuth 2.0 On-Behalf-Of flow. The OAuth 2.0 On-Behalf-Of flow (OBO) serves the use case where an application invokes a service/web API, which in turn needs to call another service/web API.
In your case, your backend API is web API A and Microsoft Graph is web API B.
A sample for your reference.
QUESTION
In this Minimal Reproductible Example I don't understand why the reducer has something (we can observe it in the ReduxDevTools) but the selector puts undefined in the component.
Could someone have keys to share about this behavior?
CodesHere are the parts of the MRE:
- actions/index.ts
ANSWER
Answered 2020-Dec-14 at 16:42As Tim Deschryver said here, the state is structured as:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install angular-oauth2
Bower: bower install angular-oauth2
NPM: npm install --save angular-oauth2
Download: angular-oauth2
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page