How to suppress the "Authentication Required" Popup from browser? - angularjs

For the invalid credentials i am getting an "Authentication Required" Popup. How to suppress this popup and let my application handle this 401 error case?

if you're using PHP.
depending on how your back end is set,
check if you have:
header('WWW-Authenticate: Basic realm="My Realm"');
header('HTTP/1.0 401 Unauthorized');
this is how it should be:
header('HTTP/1.1 401 Unauthorized', true, 401);
see PHP header() docs.

Related

Python "Invalid To header" when sending mail with drafts id

I want to send e-mails that I saved as drafts with Python. But I have an issue with the following error
raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 400 when requesting https://gmail.googleapis.com/gmail/v1/users/me/drafts/send?alt=json returned "Invalid To header". Details: "[{'message': 'Invalid To header', 'domain': 'global', 'reason': 'invalidArgument'}]">"
This is how I send it
s1=service.users().drafts().send(userId='me', body={ 'id': 's:7341000979429260348' })
I think I did everything right but I am facing this error.

Firebase Auth Apple Sign In for Web "INVALID_CLIENT" error?

I'm using firebase to implement Sign in with Apple on my React web application. I have created an AppID, Service ID with Sign in with Apple enabled. Created a Key, configured and completed the required steps as outlined here. However I still get the following error response when signing in with apple. I have implemented both Facebook and Google signin with no issues.
{
"error": {
"code": 400,
"message": "INVALID_IDP_RESPONSE : Error getting access token from https://appleid.apple.com, OAuth2 redirect uri is: https://rideup-984a6.firebaseapp.com/__/auth/handler, response: OAuth2TokenResponse{params: error=invalid_client, httpMetadata: HttpMetadata{status=400, cachePolicy=NO_CACHE, cacheDurationJava=null, cacheImmutable=false, staleWhileRevalidate=null, filename=null, lastModified=null, retryAfter=null, headers=HTTP/1.1 200 OK\r\n\r\n, contentSecurityPolicies=[], originTrials=[], cookieList=[]}}",
"errors": [
{
"message": "INVALID_IDP_RESPONSE : Error getting access token from https://appleid.apple.com, OAuth2 redirect uri is: https://rideup-984a6.firebaseapp.com/__/auth/handler, response: OAuth2TokenResponse{params: error=invalid_client, httpMetadata: HttpMetadata{status=400, cachePolicy=NO_CACHE, cacheDurationJava=null, cacheImmutable=false, staleWhileRevalidate=null, filename=null, lastModified=null, retryAfter=null, headers=HTTP/1.1 200 OK\r\n\r\n, contentSecurityPolicies=[], originTrials=[], cookieList=[]}}",
"domain": "global",
"reason": "invalid"
}
]
}
}
Please help me solve this isssue.
I was also facing this issue.
For me the error message "invalid_client" was a little bit misleading.
By following the docs of firebase on how to setup the apple signin method, you also need to create a private key in the apple developer console and paste it into your firebase settings.
What it fixed for me was, that I provided the private key Name instead of the key ID in the firebase settings.
You can find the Key ID, besides the name, in the detail view of the key, you created.
Key ID in Firebase Settings

Positive Scenario Usage of StatusReport google home trait

In Google documentation, they explained how to use "statusReport" trait for query intent when there is an error or exception occurred for a device. I'm facing issue while using it for success status without any exception. I tried sending the response with simple status as SUCCESS, Google Home is saying the response "Sorry Unable to reach device".
The response which I was sending:
{ "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf", "payload": { "devices": { "123": { "online": true, "status": "SUCCESS" } } } }
can anyone help me to solve this issue?
After looking at the code, it is clear that you’re not sending the correct & complete response of the StatusReport trait. Your response contains the online attribute but missing the currentStatusReport attribute (it is required as it defines the current error statuses of the associated device IDs). For more information, visit https://developers.google.com/assistant/smarthome/traits/statusreport?hl=en

Files GraphAPI do return 403 until the file is loaded by the user

As User#1, we're using this API to create a shared link:
https://graph.microsoft.com/v1.0/drives/{{driveId}}/items/{{itemId}}/createLink
This is successful and returns a ShareURI.
As User#2, we're using this API to get information about the item shared by User#1.
https://graph.microsoft.com/v1.0/shares/{{base64ShareURI}}/driveItem
However, /driveItem returns a status code of 403 with the following body:
HTTP 403
{
"error": {
"code": "accessDenied",
"message": "The sharing link no longer exists, or you do not have
permission to access it.",
"innerError": {
"request-id": "73e65e0a-54b8-4722-9726-82297076276e",
"date": "2018-11-07T16:20:03"
}
}
}
To prevent this 403 from happening, User#2 needs to load the ShareURI in a web browser. Once User#2 does this, then the request to the exact same URI
https://graph.microsoft.com/v1.0/shares/{{base64ShareURI}}/driveItem
return 200OK and the expected json body.
Why does User#2 have to load the ShareURI in a browser before being able to use Graph APIs on that ShareURI? Is there a workaround?
To open it directly without visiting link just add header Prefer with value redeemSharingLink to request https://graph.microsoft.com/v1.0/shares/{{base64ShareURI}}/driveItem.
Docs:
redeemSharingLink should be considered equivalent to the caller navigating to the sharing link the browser (accepting the sharing gesture)
Reference: https://learn.microsoft.com/en-us/graph/api/shares-get?view=graph-rest-1.0&tabs=javascript

CodenameOne - how to catch HTTP 404 error using Terse REST API

How can I catch an HTTP 404 error using the Terse REST API in CodenameOne? At the moment the default error handler gets this but I would like to display my own message instead. The code I am using is fine if the accountNo exists and I can deal with the resulting JSON, but if not I get the standard error handler displaying the 404 error:
Response<Map> jsonData = Rest.get( URL + "lookup").
jsonContent().
queryParam("account",accountNo).
getAsJsonMap();
This seems to be a mistake in that version of the method. It should fail silently without a UI Dialog. We'll fix it for the next update.
Notice that jsonData should have the error response code within it as jsonData.getResponseCode().

Resources