watson-developer-cloud / tone-analyzer-nodejs

Sample Node.js Application for the IBM Tone Analyzer Service
https://tone-analyzer-demo.ng.bluemix.net/
Apache License 2.0
453 stars 273 forks source link

Browser-based access to an authorization token for Tone Analyzer #93

Closed ToonTalk closed 7 years ago

ToonTalk commented 7 years ago

In order to receive the authorisation token users currently need to run CURL or the like. The enhancement I suggest is to make https://gateway.watsonplatform.net/authorization/api/v1/token?url=https://gateway.watsonplatform.net/tone-analyzer/api support CORS so a web page can get a token to use in subsequent tone analyser API calls until it expires.

What I want is for students to be given a URL to which they add ?user=: and the web page passes the information to http://gateway.watsonplatform.net/authorization. This doesn't work due to CORS errors. Once the token is available there no longer are CORS errors but to obtain an authorization token for the tone analyser the students would need to do complex and error prone steps outside of the browser.

Note that schools (and corporations) often make it difficult to install any software (e.g. CURL) so a pure browser-based solution is strongly preferred.

Note that there was no similar problem with the Vision Recognition API since the browser can pass the API key without a CORS error.

I don't know which other Watson services like the Tone Analyzer rely upon authorization tokens instead of API keys and hence would also benefit from this change.

nfriedly commented 7 years ago

Hi @ToonTalk,

While I don't foresee this capability being offered directly in the near future, I put together a quick little server that you can run to provide this capability to your students: https://github.com/watson-developer-cloud/token-generator

You could run it on a Bluemix instance or, if permitted by the school, run it on a computer in your classroom (your PC, a Raspberry Pi, etc.) or that you provide elsewhere.

Other Notes:

ToonTalk commented 7 years ago

Thanks. That will be helpful when we are ready to trial things in schools.