Watson Studio Translator API credentials for jypter notebook - watson

I'm trying to follow a tutorial, learn some more about calling APIs from a notebook. Seems the tutorial directions are no longer aligned with the bluemix platform as I'm supposed to provision a translator service, then pull my username and password from the credentials. As the only credentials created look like the below credentials, can someone please tell me how I find the username and password?
{
"apikey": "uK7Wv6hfKjTO_p56lhzZy302QmTZCyPI_FYFkqMLGOS0",
"iam_apikey_description": "Auto generated apikey during resource-key operation for Instance - crn:v1:bluemix:public:language-translator:us-south:a/bff2d8201267d05e8b5580a56638c7a0:5eb84a08-7dd1-4a12-8385-b1eb043e1fcc::",
"iam_apikey_name": "auto-generated-apikey-eb2957a2-f849-4f89-a830-2f6d688ec4a9",
"iam_role_crn": "crn:v1:bluemix:public:iam::::serviceRole:Manager",
"iam_serviceid_crn": "crn:v1:bluemix:public:iam-identity::a/bff2d8201267d05e8b5580a56638c7a0::serviceid:ServiceId-2588fac4-f9ea-4461-8e6c-be358855f9c7",
"url": "https://gateway.watsonplatform.net/language-translator/api"
}

Have you followed these instructions:
https://www.ibm.com/watson/developercloud/language-translator/api/v3/curl.html
ibm.com ? If you can share your tutorial that might also help. (Also, your question exposed your api key; I recommend deleting it and making a new one.)
Here's an example curl call:
curl --user apikey:{apikey} "https://gateway.watsonplatform.net/language-translator/api/v3/identifiable_languages?version=2018-05-01"
where the username is apikey and the password is the actual api key (for curl). This may also be helpful:
https://console.bluemix.net/docs/services/language-translator/getting-started.html#gettingstarted

Related

Unable to send google container registry in docker image

I'm trying to send my first image to gcr(google container reg.) via local bash, but somehow I couldn't do it even though I added my current user as 'owner' to the project. In the last link that gave me an error, the following was written.
{"errors":[{"code":"UNAUTHORIZED","message":"Unauthorized access."}]}
Also, my ubuntu distribution ip that I use on wsl2 was banned by google on the grounds that I tried too much. This is my 2nd problem that I need to solve.
I encountered my problem in the first item through powershell on my local computer.
What should I do in this case?
The refusal to connect to GCP might be related to the IP ban that you mentioned, was there any specified length to the ban? Usually, an email is sent with more details about the ban. Otherwise, there is specific documentation dealing with authenticating to Container Registry. The documentation lists several authentication methods:
gcloud credential helper
Standalone credential helper
Access token
JSON key file
Which of these methods are you having issues with? The documentation lists the procedure to authenticate properly with each of these methods. Is the correct account configured? It could be a different account or a service account is being used instead.

Implementing Oauth2 from scratch

I want to implement Oauth2 protocol from scratch for study purposes.
I'm following the Github guide after having created an App with a Client ID and Client Secret.
The two information sources are pretty simple and are:
https://developer.github.com/apps/building-oauth-apps/authorizing-oauth-apps/
https://gist.github.com/technoweenie/419219
In particular, I'm starting from the first step pasting on my browser:
https://github.com/login/oauth/authorize?client_id=&redirect_uri=http://localhost:8080/auth/temp&scope=user&state=&allow_signup=true
I have a Spring application listening on port 8080 (I don't want to use Spring Security because I want to implement the protocol from scratch) with the following and working endpoint exposed:
#RequestMapping("/auth/temp")
public String redirectAuth(HttpServletRequest request) {
//TODO implement next steps
return "here we are!";
}
but when I go to the github link I get a 404 not found error, as my localhost application wouldn't exist.
I expect the official guide has some mandatory information missing, such as some other endpoints which my application must expose in order to be queried, for instance, about the client secret.
So, what am I missing?
Github only supports the auth code oauth 2 flow. It might be helpful to read up on that.
I have a blog and a video on the auth code flow that may help.
Disclaimer: I work at and created them for Ping Identity, but I think
they'll be helpful even for your study purposes.
https://developer.pingidentity.com/en/blog/posts/2019/what-are-oauth-2-0-grant-types-part-1-authorization-code-flow.html
https://youtu.be/eg7I8x-u0sc
You haven't included your client_id in the authorisation url:
https://github.com/login/oauth/authorize?client_id=&redirect_uri=http://localhost:8080/auth/temp&scope=user&state=&allow_signup=true
The authorization server (GitHub) needs this value to identify the client you have registered.

Google Assistant SDK refusing authenticated channel as "UNAUTHENTICATED"

I am trying to create a Google Assistant for my Raspberry Pi in Kotlin. I implemented a OAuth flow using the so called "device flow" proposed in this IETF draft, since my Raspberry shall later just expose a web interface and does not have any input devices or graphical interfaces.
Google does support this flow (of course) and I obtain a valid access token with user consent in the end. For testing purpose I also tried a default authorization flow that will just forward the user to localhost, as it is normally done but it did not solve the problem.
I tested the access token using this tool and it confirmed validity of scope and token. So the token itself should work.
Scope is: https://www.googleapis.com/auth/assistant-sdk-prototype as documented here
This actually does not point to any valid web resource but is referenced in every documentation.
Then I tried to stream audio data to the assistant SDK endpoint using the gRPC provided java stubs. As took a third party reference implementation as a guide how to authenticate the rpc stub. But neither the reference implementation nor my own one works. They both report
io.grpc.StatusRuntimeException: UNAUTHENTICATED: Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
The stub is authenticated this way:
embeddedAssistantStub.withCallCredentials(
MoreCallCredentials.from(OAuth2Credentials
.newBuilder()
.setAccessToken(
myAccessToken,
myAccessTokenExpirationDate))
.build()))
and the authenticated request is performed like this:
val observer = authenticatedEmbeddedAssistantStub.converse(myStreamObserverImplementation)
observer.onNext(myConfigConverseRequest)
while(more audio data frames available) {
observer.onNext(myAudioFrameConverseRequest)
}
observer.onCompleted()
(I prefixed pseudo variables with "my" for clarity, they can consist of more code in the actual implementation.)
I even contacted the author of this demo implementation. He told me, last time he checked (several months ago) it was working perfectly fine. So I finally ran out of options.
Since the client implementation I took as reference used to work and I do actually authenticate the stub (although the error message suggests the opposite) Probably, either my valid access token with correct scope is not suitable chosen for the assistant API (though I followed the suggestions of google) or the API servers had a change not properly documented in the getting started articles by google.
So: Did anyone ran in the same problem and know how to fix it? I have the project on github. So if anyone needs the broken source code, I can do a temporary commit that produces the error.
Note, to save some works for mods: This issue referres to this and this question, both unresolved and using different languages but describing a similar problem.
Well, seems I was right about my second assumption: The error is server side. Here is the github issue, let's just wait for the fix.
https://github.com/googlesamples/assistant-sdk-python/issues/138

Firebase: Access the database from URL

In my Swift app, I am going to be using Vungle for incentivized ads. The way this works is that the Vungle Servers will ping any URL that I give them. For example:
myapp.firebase.com/db_location/section/user_id/?value=123
I have looked around lots of websites and now my head hurts as I cannot seem to find a solution. Is there a way to insert into my Firebase database (securely, without write all access) request that is sent via a URL?
This would be similar I assume to the API Gateway that AWS supplies.
Looking for advice, pointers/tutorials etc.
You can use Firebase REST API which allows you to insert into your database using POST requests.
An example using curl from the documentation:
curl -X POST -d '{"user_id" : "jack", "text" : "Ahoy!"}' \
'https://samplechat.firebaseio-demo.com/message_list.json'

"Missing Access Token" in google-api gem

I'm trying to use the command like google-api gem with the prediction API. I think I've been doing this exactly as I've been reading, but it keeps giving me the error "Missing Access Token".
First I authenticate via oauth1. It brings me to the log in page where I log in and grant access. After I log in, it closes and there is a file created in ~/.google-api.yaml with a token_credential_secret and token_credential_key.
google-api oauth-1-login --scope https://www.googleapis.com/auth/prediction
I should be authenticated now aren't I? When I try to execute a command, it get Missing Access Token.
google-api execute prediction.training.insert "data=bucket/train.csv"
I've been scouring the internet for this answer, but without much luck. It also doesn't help that google's docs usually aren't up to date.
I removed the docs that were out-of-date. Let me know if you see anything else that's out-of-date. Main issue is simply that I've been the person building the Ruby client and now I'm moving to Kenya, and the people who are taking it over are still ramping up. Please bear with us.
Do this instead:
bin/google-api oauth-2-login \
--scope=https://www.googleapis.com/auth/prediction \
--client-id=<your-client-id> \
--client-secret=<your-client-secret>
Then you can make your API calls:
google-api execute prediction.training.insert -- data=bucket/train.csv

Resources