Does the DocumentTranslator app support Azure china translation services? - microsoft-translator

DocumentTranslator 这个APP是否支持 中国区的Azure翻译服务
ERROR Unauthorized
{
"error": {
"code": 401000,
"message": "The request is not authorized because credentials are missing or invalid."
}
}

You do not contain a correct authentication method in the request header

Related

how can i call HTTP callable cloud function from postman?

I want to know that can i call cloud function from postman software .When i'm calling CF from postman it always give me
"error": {
"status": "INVALID_ARGUMENT",
"message": "Bad Request"
}
In Postman make post request, header Content-Type should be application/json and then in raw make json in this format
{
"data": {
"text":"hi how are you",
"phoneNumbers":"+92123455679"
}
}
Using #Vaaljan's answer I was able to authenticate a GCP cloud function that I created using the HTTP trigger method with authentication required:
gcloud auth print-identity-token
Then added it to the request Authorization header:
Authorization: Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6I ... bnRzLmdvb2dsZS5jb20i
In Postman:
Could possibly also be that the cloud function is protected and can be invoked by adding Authorization header with the identity token as the Bearer.
You get the identity token by running
gcloud auth print-identity-token

how to Create subscription for sent items folder using Microsoft graph api

following post request give an error when creating a subscription for the Sent Items folder using Microsoft Graph
var apiUrl = "https://graph.microsoft.com/v1.0/subscriptions";
Request
{
"resource": "me/mailFolders('Sent Items')/messages",
"changeType": "created,updated,deleted",
"clientState": "320a6f10-9c62-4e59-a395-8cd27941b597",
"notificationUrl": "https://webhook.site/aaaa-6f49-4906-aaaa-e911f9391695",
"expirationDateTime": "2018-08-28T12:53:41.4830081+00:00"
}
Error Response
{
"error": {
"code": "ExtensionError",
"message": "Operation: Create; Exception: [Status Code: BadRequest; Reason: Bad Request]",
"innerError": {
"request-id": "359f51a6-5b12-41f6-8a02-a68ba4c10585",
"date": "2018-08-27T06:42:18"
}
}
}
Unfortunately the webhook.site test site that you are using does not implement the validation token protocol that is required to setup a subscription. The webhook must return the value of the validationToken query parameter in the response body for the subscription to be created correctly.
i changed the resource property value for folder name 'Sent Items' to 'SentItems' . here is the working request
{
"resource": "me/mailFolders('SentItems')/messages",
"changeType": "created,updated,deleted",
"clientState": "320a6f10-9c62-4e59-a395-8cd27941b597",
"notificationUrl": "https://webhook.site/aaaa-6f49-4906-aaaa-e911f9391695",
"expirationDateTime": "2018-08-29T12:53:41.4830081+00:00"
}

Microsoft Graph API: Subscribing to MailboxSettings

Is it possible to subscribe to changes of MailboxSettings - specifically AutomaticRepliesSetting?
Trying to POST this to /subscriptions on the beta API.
{
"changeType":"updated",
"notificationUrl":"https://example.com/microsoft/notify",
"resource":"users/karel#example.com/mailboxSettings",
"expirationDateTime":"2018-05-11T08:05:26.6920740Z",
"clientState":"QUUvRXJ5beHI9VEvn6hq"
}
Getting back:
"code": "ExtensionError",
"message": "Operation: Create; Exception: [Status Code: Forbidden; Reason: Forbidden]"
The application has admin consent for Calendars.ReadWrite, User.Read.All and MailboxSettings.ReadWrite
I can successfully subscribe to calendar changes, so nothing is wrong with the implementation.
Subscribing to the root /users/karel#example.com endpoint gives:
{
"error": {
"code": "ExtensionError",
"message": "Operation: Create; Exception: [Status Code: InternalServerError; Reason: Internal Server Error]",
"innerError": { "request-id": "3caffc72-9507-4bb7-9eab-56e8ecaaab83", "date": "2018-05-08T09:22:16" }
}
}
This isn't supported. From the documentation:
Using the Microsoft Graph REST API, an app can subscribe to changes on the following resources:
Messages
Events
Contacts
Users
Groups
Group conversations
Content shared on OneDrive including drives associated with SharePoint sites
User's personal OneDrive folders

Good practice for JSON error response for 400 and 500

I have read many RESTful API design pattern resources.
But I'm not confident for deciding API.
It seems there does not not exist a standard JSON response format.
I need advice for my Json error response as below.
401
jwt token related fail
{
code:1,
message: "no access token"
}
{
code:2,
message: "invalid access token"
}
{
code:3,
message: "expired access token"
}
400
client's insufficient input parameter
{
code:20,
message: "input paramter 'search' is missing"
}
client's invalid value request
{
code:21,
message: "invalid serial no"
}
client's invalid request format
{
code:22,
message: "input parameter indate is invalid date format"
}
500
another mesh-up server's problem
{
code:30,
message: "no reply from external server API"
}
program logic error (ex. exception)
{
code:31,
message: "internal server error"
}
For 500 cases, I think client also needs more information.
And another concern is "Is error code needed?"
You could use Problem Details for HTTP APIs.
It's a nice format that can be extended easily to provide the client a good way to react on each error/problem appropriately.
https://www.rfc-editor.org/rfc/rfc7807
Here is an example taken from the RFC:
{
"type": "https://example.com/probs/out-of-credit",
"title": "You do not have enough credit.",
"detail": "Your current balance is 30, but that costs 50.",
"instance": "/account/12345/msgs/abc",
"balance": 30,
"accounts": ["/account/12345", "/account/67890"]
}

Google Search Console 401 Bad Request issue without using Client Library

So, Here are 3 steps.
I called oAuth2 with following url:
https://accounts.google.com/o/oauth2/v2/auth
?scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fwebmasters%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fwebmasters.readonly
&client_id=___.apps.googleusercontent.com
&redirect_uri=urn:ietf:wg:oauth:2.0:oob
&response_type=code
&approval_prompt=force
&access_type=offline
I get the code, suppose: 4/QVgPaCMqp94____qBC4NY_d54IcRj7U9mJc
Then I'm making a request for access_token, by making a POST request to https://accounts.google.com/o/oauth2/token with client_id, client_secret, redirect_uri, grant_type, and I get a JSON like:
'access_token' => ya29.CjHzAgC4js6Guv-1pt_rE____q8XIxiXOXOaSZW9NLRjKCTI3izBi,
'expires_in' => 3600,
'refresh_token' => 1/dL3ENA-EVI0rEb6D-OGqw_____iFe2ZNdEq4,
Now, I am making a request with that access_token or in cases of expiry with a renewed access_token to Google Search Console, which I have added in scopes.
My request is similar to this: https://developers.google.com/webmaster-tools/v3/urlcrawlerrorssamples/list#try-it
But I get an 401 unauthorized error, with a json like following:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Login Required",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Login Required"
}
}
Considering I have done the process correctly, I think I have missing some parameters or providing some wrong value.
I have not used Google Client Library, instead used the REST API framework directly.
Can anybody give some clue please? Thank you.
The reason is, URL query parameter must be ?access_token= and not ?key= The later can be used only in case of direct API access and not oAuth.