Usually received 400 status code from Google Identity OAuth 2.0 - actions-on-google

I'm working on the project that implement SSO feature using Google APIs and services. The implementation is in the backend which used Nestjs as an authentication micro-service.
My logic using authentication code return from consent screen after signin success, then that code will be used to getToken from GG Apis. Sometime the return will be as status code 400 and message is: invalid_grant. I'd studied about this problem for a week, but no clue for me.
Can anyone tell me why this is happen, and why it not happen for all request, about 20% of request will return this error message.
FW/lib:
Nestjs/core: ^8.0.0
googleapis: ^95.0.0

Related

Using token authentication with flutter swagger_dart_code_generator

I'm currently learning flutter and how to develop mobile apps with a server backend. I've came across the library swagger_dart_code_generator, which generates Dart Models and API functions based on a swagger file.
I have followed the example they have and I managed to get myself a basic working REST Application.
So my request to api.userLogin(); returns a JWTToken as expected.
The next step was figuring out, how to send a JWTToken with requests that require authentication, but I found no examples in their GitHub repository, nor did I see a Member Function in the generated code, that lets me set headers to the HTTP request.
What I am basically trying to do, is to send the JWTToken I already got to a function like api.getSuperSecretUserInfo(); and get a response from the Server other than a "401 Unautherized".

Flutter : Exception caught by image resource service

HTTP request failed, status Code: 403, when I try to call Map Api in flutter Here is the screenshot
Anyone please help me out
The url shown in your screenshot returns the following message along with the 403 code:
The Google Maps Platform server rejected your request. You must enable Billing on the Google Cloud Project at https://console.cloud.google.com/project/_/billing/enable Learn more at https://developers.google.com/maps/gmp-get-started
You therefore have to do three things, in you code and on the Google cloud console:
Ensure that you trap and report any error message returned from the api in order to better understand the response code.
Cancel the api key that you have now published to the world and generate a new one for the Google maps api, in cloud console.
Enable billing on your project otherwise Google maps api will never work as it is a chargeable service.
Hope this helps. As I said, NEVER publish api keys nor store them on GitHub or similar.
Sorry to say but error 403 means you don't have any access to that image from the server side.

An error occurred while sending the request with PostAsJsonAsync

I have a soap web service which is being consumed by an application. This web service when called from the application posts the data it receives by a call to another web service via POST request using "PostAsJsonAsync". Sometimes the call to the other web service goes through but sometimes it throws an error - "An error occurred while sending the request". There is no specific use case or data scenario when this happens. It just happens at random.
The other service uses a token authentication system. The token is getting generated correctly in every case but the call doesn't go through for some.
Could anyone please guide me what might be the root cause for this issue?
The issue was with certificate validation with request. Resolved by adding this piece of code before making the http post call - ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };

401 Unauthorized - Exception

I face a problem today regarding the connectivity with Orion public instance #http://orion.lab.fi-ware.org:1026/ngsi10/contextEntities/{entity_id}. While, two days ago, I got always connection to the orion public instance, always by using the same Authentication Token, I got from FI-WARE, Today when I'm trying to connect I get an error: "GET http://orion.lab.fi-ware.org:1026/ngsi10/contextEntities/urn:smartsantander:testbed:3337 returned a response status of 401 Unauthorized".
I was and continue to use the Jersey REST API so as to connect with NGS10 Orion REST API Implementation.
Is there any idea about what I have to do to solve the problem? Is this a problem in Orion Server side with the Authentication Service?
Thank you in advance!
Probably the token has expired. You can re-generated a fresh token runing the token_script.sh script, as described in the following document.
EDIT: the normal behaviour of the system is to cancel the token from time to time, so the best approach is regenerate it with a given periodicity (e.g. 24 hours). However, note that although you can manually regenerate the token and recofigure your application to use the new one as described above, it is better to program your application to do it automatically.
Please, have a look to the OAuth course in FI-WARE education platform and the Refresh Token section in the OAuth 2.0 RFC for more information.

Twitter+oAuth engine returning 401 when trying to post status

I am using the Twitter+oAuth engine in my iPhone app, and I am able to authenticate the user perfectly. I can get statuses with no issue at all, but when I want to post a status, a 401 error is being returned.
This is how I am sending a tweet: [_engine sendUpdate:#"Testing 101"];
It is returning a "Request failed" message with a HTTP 401 error. When I use the same engine to receive statuses, a request succeeded message is being returned.
Why is this happening?
I can receive statuses perfectly, multiple times a minute. That request is succeeding with no difficulty, but the same engine is returning a 401 when trying to post.
Make sure your callback url is not blank. This callback url does't have to be valid, or even exist.
Try not to submit the same update over and over. Twitter sees this as spam and will eventually refuse to post your updates.
Also, see Twitter Error & Response Codes.
401 Unauthorized Authentication credentials were missing or incorrect.
This leads me to think too, that you aren't logging in or passing the correct credentials before posting.