I am willing to translate a particular text in 3 different languages using using Microsoft Translator API. I configured it and, apparently, the link I get which should drive me to translation breaks:
https://api.datamarket.azure.com/Data.ashx/Bing/MicrosoftTranslator/v1/Translate?Text=%27Osteopathy%27&From=%27en%27&To=%27nl%27&$format=Raw&$top=100
I tried it also in my terminal with curl, with authorization, but it seems that no response is sent:
$ curl -H 'Authorization: Basic ***my authorization_key encoded in base64***' 'https://api.datamarket.azure.com/Data.ashx/Bing /MicrosoftTranslator/v1/Translate?Text=%27Osteopathy+for+Babies%27&From=%27en%27&To=%27nl%27&$format=Raw&$top=100'
The response from Microsoft Translator doesn't come. It simply times out.
The same piece of code worked few weeks ago.
What could be the cause? How to fix this?
I tried the same request as you and I do get a response back from the server but it's a 403 forbidden. I can't speculate on why the code no longer works but if you also get back a 403 it might be worth refreshing the key, it might have expired somehow. Otherwise the behaviour of the API has changed in a breaking way, it's hard to say without any official documentation.
However, you could try the Microsoft Cognitive Services API, it took be about 5 mins to setup. You will need to use OAuth bearer tokens instead of basic auth, but this is more secure anyway.
Setup docs
https://www.microsoft.com/en-us/translator/getstarted.aspx
Getting a token
http://docs.microsofttranslator.com/oauth-token.html
And some code samples
on github under MicrosoftTranslator/HTTP-Code-Samples
Azure Datamarket has been closed - there is more information here about moving to Azure:
https://translatorbusiness.uservoice.com/knowledgebase/articles/1078534-action-required-before-april-30-2017-microsoft-t
Related
I am new to GoogleAPIs and Laravel, I run a PHP web application on Laravel 8 in a virtual Linux environment. Socialite and Drive API was working fine and out of sudden it doesn't work anymore and always return connection refused error after long period of loading as follows:
GuzzleHttp\Exception\ConnectException
Connection refused for URI https://www.googleapis.com/oauth2/v4/token
I had tried to create a new credential with new refresh token and checked all the network settings, and always clear config cache and restart apache for all troubleshoots I have tested, yet the error still exists.
I would appreciate it much if anyone could enlighten me on what are the aspects I shall look into it.
There are multiple issues in this question.
First and foremost, you are sending your secret to a third party. This means that they are able to do any API calls as you (using your name and quotas). Even if they claim that they won't, they can. Please remove any secret you may have and create new ones.
As for the OAuth 2.0, you seem to be using an old URL. You should probably take a look into the official documentation for:
Using OAuth 2.0 to Access Google APIs for a basic explanation.
Using OAuth 2.0 for Web Server Applications for making a web and getting permissions to get/modify a user's data (can be yourself).
Using OAuth 2.0 for Server to Server Applications for using a service account to execute as one of the users on your organization, without the need of manually giving permission.
Also notice that there are PHP libraries officially supported by Google to make your life way easier. See the Drive API's PHP Quickstart.
I am trying to implement Google Cloud Task queues with a HTTP Target. I've used the queues for App Engine but in moving to Cloud Run I wish to use the same queue system. I have implemented the dispatcher code but unlike App Engine I can't trust the headers so I'm aware I need to verify the request using an auth token but I'm struggling to get my head around it? I'm making a lot of assumptions as well. I'm trying to build this in PHP so if possible it would be good to see an example in PHP but even just some Psuedo code of the flow would be useful.
My first assumption is it's best to use OIDC Tokens? based off of:
if you are writing your own code in the targeted service to validate
the token, you should use an OIDC token. For more information on what
this entails, see OpenID Connect, particularly Validating an ID token.
I've read the linked heading for this but it didn't make much of it clear to me if I'm honest.
Secondly tokens will be in the Authorization header as Bearer <token>?
Thirdly I guess I should use something like the package firebase/php-jwt to decode the token. But how do I decoded it exactly? My service JSON file only has a private key, do I need to grab the public key from the cloud console? Once I do that is there particular parts of the token I need to look at to verify the request? Or should the fact I can decode it into valid JSON be enough?
Everytime I read a bit of documentation on how to do it I think I'm getting closer to the answer but I'm at the point it's taken far longer than I'd like and it's a bit frustrating when Google documentation rarely seems to just point out what I need to do.
You can refer to the link : https://developer.okta.com/blog/2019/05/07/php-token-authentication-jwt-oauth2-openid-connect
for more information about how to create http tasks with authentication tokens for cloud run. Note that the code is given for python, jave, GO, and node.js. But it will give you an idea of the flow.
A request example of the authorization header (https://developer.okta.com/docs/reference/api/oidc/):
curl -v -X POST
-H "Authorization: Bearer ${access_token}"
"https://{baseUrl}/userinfo"
Information on how to decode the token:
https://developer.okta.com/blog/2019/05/07/php-token-authentication-jwt-oauth2-openid-connect
Hello to all
I am new in Amazon Alexa, I have a work to Alexa Skill account linking using PHP with oauth 2.0.
I have successfully configured all and also get code for Auth Code Grant but when I run my code in Chrome Browser it is generating Account linking Failed issue but when I run same URL in Firefox it generates Amazon linking failed with ERROR=missing-state.
Please help me to resolve my issue, any help would be highly appreciated.
Implementing Account Linking is tricky at times. The thing is at some point what happens between Alexa and the OAuth2 server is transparent for the Skill (Lambda), for example the process of refreshing a token among others, that is why I suggest you take a look at the references cited below.
Also because of the error shown, it seems that the parameter code is missing in one of the URLs exchanged back and forth between either the Alexa web console or Alexa mobile app and the OAuth2 server. Please verify it is always the same and is always present in the URLs. Implementing a proxy for sure will help on debugging this issue.
I would suggest you take a look at these great sources:
Debugging Account Linking
Using API Gateway to Debug Account Linking issues
I hope this helps somehow.
Cheers
I have gone through links that provide some CURL request samples for AZURE push notifications but none of them works for me.
Like in this url CURL request using Ruby language is provided but like others it is also not working.
"Internal Server Error (500)"
occurred every time when I made a request using CURL requests.
If anybody can provide me with working code of CURL request for AZURE push notifications then it would be convenient for me to solve the issue. Keeping in mind that push notifications from web portal of AZURE are working absolutely fine.
May I know whether you are using Azure Service Bus Notification Hub? If so, the most likely problem from my experience is you may haven't formatted the request properly. It’s needed to prepare the following information, and send them in request headers:
Content-Type: Based on the platform you choose, the value will be different. For instance, for Windows Store apps, content type is application/xml.
ServiceBusNotification-Format: The device type, such as windows.
X-WNS-Type: Push notification type, such as wns/toast.
Authorization: The rules are described in https://msdn.microsoft.com/en-us/library/azure/dn495627.aspx. Pay special attention to the Create SAS Security Token part.
And the request content. The format is different for different devices. For example, for Windows Store apps, it’s needed to use xml like:
<?xml version="1.0" encoding="utf-16"?><toast><visual><binding template="ToastText01"><text id="1">Hello!</text></binding></visual></toast>
If you're using CURL command line, please make sure to use double quotes instead of single quotes.
Also please make sure you have correctly registered the push notification service provider in Azure. For instance, for Windows Store apps, please register the SID and the client secret.
If the issue is still encountered, please share more information. It would be better if you can let us know:
• Are you trying to use the CURL command line or PHP code?
• What kind of device you're using?
• What kind of message you want to send?
I want to access, view, modify Google docs but via a program written in php.
I would prefer to use API protocol as it can be used by any language.
But apparently the API requires me to be signed in in a browser. Now if I want to make a server side script that apparently wont be running in a browser, how can I do that?
I didnt found any username/password/auth giving thing that returns me some token and the API can use that token.
https://developers.google.com/google-apps/spreadsheets/#changing_contents_of_a_cell
google would not know who sent the second request if it does not has the access token or some way to prove that it logged in a minut a go. in my case: the program (lets say php server)
I guess this would not help https://developers.google.com/google-apps/spreadsheets/#authorizing_requests for https://developers.google.com/google-apps/spreadsheets/#changing_contents_of_a_cell as the later has no access token option.
You should authenticate your clients with OAuth2 and then store the tokens in db: https://developers.google.com/drive/web/auth/web-server
Also there's a client library available from Google: https://developers.google.com/api-client-library/php/
Edit: As you said it's about the spreadsheet API I'm linkin directly to the spreadsheet API authentication documentation: https://developers.google.com/google-apps/spreadsheets/#authorizing_requests_with_oauth_20 seems they support OAuth2 too.
Thanks to all but I found something working exactly as required.
http://framework.zend.com/manual/1.12/en/zend.gdata.html