What is correct way to get access to YouTube Data 3 API? - youtube-data-api

Dear YouTube Data 3 API support, it's a question for you.
With https://github.com/googleapis/google-auth-library-ruby using json-key that we got to Service Account, we successfully get [TOKEN_KEY] for API calls.
But while we try to get Live Streaming list we get an error:
{
"message": "The user is not enabled for live streaming.",
"domain": "youtube.liveBroadcast",
"reason": "liveStreamingNotEnabled",
"extendedHelp": "https://www.youtube.com/features"
}
The request sample:
curl \
'https://youtube.googleapis.com/youtube/v3/liveBroadcasts?part=snippet%2CcontentDetails%2Cstatus&broadcastType=all&mine=true' \
--header 'Authorization: Bearer [TOKEN_KEY]' \
--header 'Accept: application/json' \
--compressed
What we have already done in Google Cloud Console:
Create a Project
Enable YouTube Dava 3 API
Create an API key
Create an OAuth ID
Create an Service Account
Connect Service Account in OAuth ID
We try some another ways but uselessly.
Of course, our account, in which we created the API application, has access for streaming through the studio.youtube.com (we have 10,000 subscribers and streams several times a week).
Also we studied the API documentation up and down, we do everything correctly step by step, as described.
I can write a private email with my account information to YouTube Data 3 support member, to make it easier for you to understand, and when we will successfully solve the problem I will write a comment to this question for the whole community.

Related

Validating token with Azure active directory user_info and token_info end points

I have an existing spring boot application which provides Rest API's and it doen't do authentication. Authentication is being handled by FrontEnd applcation and for evert API request from FrontEnd, we receive token in the Request Headers(authorization) and we validate this token by calling below 2 service provider endpoints using org.springframework.web.client.RestTemplate before proceed with the API requests. For this we have written an interceptor to intercept every request and validate the token.
Token Info end point to validate token and User Info endpoint to get User Details.
UserInfo: https://dev-login.iam.organisation.com/organisationsso/oauth2/userinfo
TokenInfo: https://dev-login.iam.organisation.com/organisationsso/oauth2/tokeninfo?access_token=
User Info Sample request:
curl -X GET \
https://dev-login.iam.organisation.com/organisationsso/oauth2/userinfo \
-H 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJub25jZSI6Il…' \
-H 'cache-control: no-cache'
Token Info Sample request:
curl -X GET \
'https://dev-login.iam.organisation.com/organisationsso/oauth2/tokeninfo?access_token=eyJ0eXAiOiJKV1QiLCJub25jZSI6Il..' \
-H 'Cache-Control: no-cache'
Now we are changing the IAM service provider to Azure Active Directory B2C and I don't have much idea on how to validate tokeninfo and userinfo with Azure AD using existing org.springframework.web.client.RestTemplate or different approach.
I have found docs for userinfo and it seems we can use RestTemplate to call the endpoint to get the user information but could not find the Rest Template approach for Token info.
Can someone guide me to the correct and simple approach to avoid the multiple changes in the existing code.
ACCESS TOKENS
For access tokens you will use JWT validation in memory - here is a Spring Boot API Example.
USER INFO
To get user info in an API is tricky - not sure if you need to do that? If so you may need to get a different (graph) token using the On Behalf Of Flow.
RESOURCES OF MINE
I remember struggling with some of this a couple of years ago, so my links below may provide a useful hint or two:
Code
Blog Post

API call for deploying and undeploying Google AutoML natural language model - documentation error?

We have a google automl natural language model and while testing, have been deploying and undeploying the model by hand on the console.
We also have a google automl image classification model in a production application and we deploy and undeploy that from our application using the API.
I am now viewing the documentation for the automl natural language model and I want to be able to deploy the model from our application as-needed and undeploy it when finished. Obviously being deployed incurs charges so we minimise these by only having the deployed capability active when needed.
The documentation page for this functionality is here
https://cloud.google.com/natural-language/automl/docs/manage-models#deploy-models
This is next to the section in the documentation that describes deleting models here
https://cloud.google.com/natural-language/automl/docs/manage-models#delete-model
In the deploy and undeploy model, it shows the API call you make for undeploy (:undeploy) but it does not specifically show the one you make for deploy (which I would assume is :deploy but this is not noted in the documentaion)
IN the delete model section, the API endpoint shown is the undeploy endpoint. The documentation specifically says that if you use the undeploy command, it deletes the model. I believe this to be a documentation error but I don't want to try it as I don't want to delete our model by mistake.
It also doesn't specifically say this but in my image model, it returns me a long running operation and I can poll for the status of that. Is that how it works on the natural language models too?
Thanks for the clarification
Richard
Deploying a model was not properly documented for the REST usage. See deploy endpoint for reference.
curl -X POST \
-H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
https://automl.googleapis.com/v1/projects/your-project-id/locations/location-id/models/your-model-id:deploy
You are correct, this might be a documentation error. Another error is when using :undeploy it should be POST not GET.
curl -X POST \
-H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
https://automl.googleapis.com/v1/projects/your-project-id/locations/location-id/models/your-model-id:undeploy
For :delete it should be DELETE not GET.
curl -X DELETE \
-H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
https://automl.googleapis.com/v1/projects/your-project-id/locations/location-id/models/your-model-id
Yes you can poll for the status that was given. See Working with long-running operations for AutoML Natural Language for more details.
I also sent a feedback on the documentation about the mistakes you pointed out.

pinterest v3 api exchange auth code for access token : invalid_grant

Using v3 Pinterest Analytics API
Trying to exchange an authorization code for an access token and I'm getting the following error:
{"error":{"message":"None","oauth_error_code":"invalid_grant"},"code":283,"data":null,"message":"The authorization grant is invalid","endpoint_name":"oauth_access_token","status":"failure"}
In following these instructions:
https://developers.pinterest.com/docs/redoc/#section/User-Authorization/Exchange-the-code-for-an-access-token
I successfully obtained an authorization code. Now I want to exchange it for an access_token. I submit the following curl:
curl -X PUT \
--url https://api.pinterest.com/v3/oauth/access_token/ \
--data "code=1234authcode&redirect_uri=https://myURL.com/&grant_type=authorization_code&client_id=123appId&client_secret=123secret"
The redirect_uri is the same as that which was registered. The app secret and app Id are accurate as per this notification we received today:
Your App ID has been enabled. You can now see your app secret in our Developer App Portal and start building.
I have tried various incarnations of the curl thinking I've botched the args I'm passing in and that's still a possibility, so any help there would be appreciated, however, I'm wondering if my app Id and secret are bad or truly invalid somehow. We've only just received them. Any ideas or theories welcome.
Thanks for your time.
Sorry to answer my own question, but it turns out that the auth code was bad. After fetching a new authorization code I was able to obtain an access_token using the approach shown above. What was initially confusing is that I literally got the original auth code moments before using it so I didn't doubt it's validity as much as I should have I guess.

Create Card through composer-rest-server

I am able to add participant using composer-rest-api and it is possible to upload card through composer-rest-api by rest API wallet. Is it possible to create Card through composer-rest-api?
I checked this answer Hyperledger Composer Web application user authentication, it mentions how to create card using javascript api. I used javascript code to create participant and issue it and when I run it ($node filename.js), it works fine. How can I add this to the rest API, which file exactly I need to modify for the rest server to be included create card.
yes sure - you would use the /api/system/issueIdentity operation as in http://localhost:3000/api/system/issueIdentity - you would get an option to save the card to a file (no credentials set, ie enrol ID and secret). You would then, again in REST, import the card (as you did) using http://localhost:3000/api/wallet/import'- and specify the card file to import from a 'Browse' (explorer) button. Once you import it to the wallet in your REST client, you can set it as the default card too usingsetDefault` endpoint operation if need be. Then use it once enrolled and indeed export it for use elsewhere. Example using curl:
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{ \ "participant": "org.acme.org.user#orguser1", \ "userID": "dave" \ }' 'http://localhost:3000/api/system/issueIdentity'
where orguser1 is your participant already created in Composer. Hope this helps.
I'm able to execute the curl command as provided by Mr O'Mahony. However, I don't know how to deal with the response I got back (please see below). Does anyone have javascript example code to handle the response? Thanks.
PK
�|eL��gDconnection.json{"name":"hlfv1","type":"hlfv1","orderers":[{"url":"grpc://localhost:7050"}],"ca":{"url":"http://localhost:7054","name":"ca.org1.example.com"},"peers":[{"requestURL":"grpc://localhost:7051","eventURL":"grpc://localhost:7053"}],"channel":"composerchannel","mspID":"Org1MSP","timeout":300}PK
�|eL�/
metadata.json{"userName":"voter114","version":1,"enrollmentSecret":"JoKCZAJxTfic","businessNetwork":"voting-network"}PK
�|eL��gDconnection.jsonPK
�|eL�/

Google API refresh token CURL

I connecting the google spreadsheet API. I have already granted permission to the user and retrieved the code. I would like to refresh the token with the refresh token, but cannot find the url. can anyone point me to the url needed? I cannot use the libraries since I am using an ETL tool and not a code to connect to the service.
Thank you
Nir
This worked for me:
curl https://www.googleapis.com/oauth2/v4/token \
-d client_id=$CLIENT_ID \
-d client_secret=$CLIENT_SECRET \
-d refresh_token=$REFRESH_TOKEN \
-d grant_type=refresh_token
For the first authorization code exchange, a refresh token is obtained in offline scenarios. In these cases, your application may obtain a new access token by sending a refresh token to the Google OAuth 2.0 Authorization server.
As discussed in the documentation, to obtain a new access token, your application sends an HTTPS POST request to https://www.googleapis.com/oauth2/v4/token.

Resources