Custom Translator API Authorization - microsoft-translator

I am trying to use the Microsoft Custom Translator API(https://custom-api.cognitive.microsofttranslator.com/swagger/)
to get list of the projects and so on. However I am receiving the 401 response (Unauthorized).
I am using the header authorization token as specified in similar Translator v3. API (https://learn.microsoft.com/en-us/azure/cognitive-services/translator/reference/v3-0-reference#authentication), however response is still 401.
The problem is not in the subscription, as the token authorization works well for the Translation v3. API.
Example of the call:
curl -X GET --header "Authorization: Bearer XYZ" https://custom-api.cognitive.microsofttranslator.com/api/texttranslator/v1.0/projects
Do you have any hints for the resolving the issue? Thank you.

I found this sample code on GitHub. https://github.com/MicrosoftTranslator/CustomTranslatorApiSamples
This sample code shows "resouceUri" is not "https://graph.microsoft.com". Please set "api://6981666b-e0e0-47d6-a039-35318677bf79/access_as_user" when you request authonize and token.
And execute ex. "https://custom-api.cognitive.microsofttranslator.com/api/texttranslator/v1.0/workspaces" and Set to header "Authorization Bearer (access token)".
If you try on swagger, you have to write "Bearer (access token)".

The Custom Translator API and the Translator V3 API are separate APIs. The Custom Translator API works with AAD v2 authentication since the operations on the Custom Translator are driven by the user as opposed to a subscription.
Please see below how to obtain an id_token for AAD v2.
https://learn.microsoft.com/en-us/azure/active-directory/develop/active-directory-protocols-oauth-get-jwt-token
The mechanism of using this token with Custom Translator API remains the same as you have mentioned above
--header "Authorization: Bearer XYZ"

Related

Google maps street view publish

What is the procedure to follow for google street view publish. Is google cloud service required?
When I tried, is returned me status Unauthorized
I tried to find an answer here already, on StackOverflow, but all are not clear. Please guide me.
This error means that the your access token is missing or incorrect. Make sure the http header contains a valid token like
authorization: Bearer YOUR_ACCESS_TOKEN
You can find out more in Google's OAuth2 documentation:
https://developers.google.com/identity/protocols/OAuth2

How to obtain data from Canvas API?

I want to obtain data through canvas API from a moodle course that our institute is doing right now. I went through the documentation and I have generated an access token as advised in the API documentation. But now I don't know how to proceed.
I tried different examples in the chrome browser console.
ex: GET https:///login/oauth2/auth? client_id=XXX&response_type=code&redirect_uri=https://example.com/oauth_complete&state=YYY
But it didn't provide me any result. Instead I got errors such as "Uncaught SyntaxError: Unexpected identifier".
Can someone please tell me where should I start?
Thanks a lot.
You can generate an Access Token by going to "Account -> Settings -> New Access Token" Then copy down the access token.
Then you can make api calls by either
Attaching that access token to your request as a header curl -H "Authorization: Bearer <token>" 'http://<canvas>/api/v1/accounts/<account_id>/courses
or
Attaching the access token as a GET query parameter
http://<canvas>/api/v1/accounts/<account_id>/courses?access_token=token_of_magical_powers
Beware that the access token has all of the same privileges as the user for whom it was generated, so keep it guarded.
More documentation and examples can be found in the canvas community pages.

Box API get shared file results in 404

Already looked at How to use box-api to get the Shared item? and Box Developers documentation https://developers.box.com/docs/#shared-items. I have tried doing a request to https://api.box.com/2.0/shared_items in .NET code, in Firefox Poster and using curl. They all resulted in 404. I have verified that my file's shared link is open to anyone with a link. Here's my curl code (sanitized):
curl https://api.box.com/2.0/shared_items -H "Authorization: Bo
xAuth api_key=xxxxxxxxxxxxxxxxxxxxx" -H "BoxApi: shared_link=https://
app.box.com/s/yyyyyyyyyyyyyyyyyyyyyyyyyyyy"
{"type":"error","status":404,"code":"not_found","help_url":"http:\/\/developers.
box.com\/docs\/#errors","message":"Not Found","request_id":"196207167555469c3017
14b"}
What might be the problem? I tried a wrong api_key and got back 401 so I know the whole setup is correct.
Your API key shouldn't be included anywhere in the request. I believe that form of authorization was used in the old v1 API and is now deprecated. There's a cURL example in the docs you linked to that shows what your authorization header should look like:
curl https://api.box.com/2.0/shared_items
-H "Authorization: Bearer ACCESS_CODE"
-H "BoxApi: shared_link=SHARED_LINK"
For more info on how to obtain the access token that goes into the authorization header, take a look at the OAuth tutorial.
The reason why authentication is required is because the API will return info about the item within the context of the caller's permissions. For example, if the creator of the shared link makes the API call, then private information (such as the item's full path within their account) will be returned. If another user makes the call, then that private information will be omitted.
That being said, you're still able to anonymously download an open shared link by navigating to it directly. You only need to use the API if you want more information about the item that the link points to.

how to call rest api for sandbox paypal for payment verification

Hi am running paypal sample application it runs perfetct (Version 2.0 paypal sdk)
i used my sandbox client id in application
after successfulle payment it gives me json output
but i want to confirm that payment am confused how i can confirm it
i got some docs where they mention to use REST api of sandbox paypal and chek with it
but i dont know how to do it
below is the link
my problem is i dont know how to call below api on browser i have access token and payment id
https://api.sandbox.paypal.com/v1/payments/payment/PAYMENT ID\
-H "Content-Type: application/json" \
-H "Authorization: Bearer {accessToken}"
when am trying to run it as it is on browser with my input parameter it shows me
{"name":"INTERNAL_SERVICE_ERROR","message":"An internal service error has occurred","information_link":"https://api.sandbox.paypal.com/docs/api/#INTERNAL_SERVICE_ERROR"}
this message please help me out please
Dave from PayPal here.
Sometimes we see that INTERNAL_SERVICE_ERROR when you have made a payment using the same PayPal account for both payer and payee.
And sometimes INTERNAL_SERVICE_ERROR means that the Sandbox server is having a transient problem, in which case trying again after some time has passed will solve the problem.
Might either of these scenarios apply in your case?

box.com api without Oauth2

I created box.com application and want to access files and folders under my account using api sdk https://github.com/box/box-windows-sdk-v2. Is it possible to not use OAuth2 for authentication(something like
curl https://api.box.com/2.0/folders/FOLDER_ID/items?limit=2&offset=0 \
- H Authorization: client_id=MY_CLIENT_ID client_secret=MY_CLIENT_SECRET) and get access only for my data.
You'll need to go through the oauth process and get a bearer token to use the Box API.
as user1989104 said: you won't get around the OAuth process. Check my answer on another thread for kind of a workaround to this issue:
Best way to upload files to Box.com programmatically