Google Cloud Java project cannot find endpoint library - java

I am trying to connect an app-engine application to a Tensforflow model running on a Vertex AI endpoint.
It works if I provide my personal authentication details but these need to be refreshed all the time.
Going through the documentation it sounds like App Engine can authenticate to an endpoint automatically using the endpoint APIs - Based on this example
Unfortunately Eclipse cannot find "com.google.cloud.aiplatform.*" and I am not sure which library should include this.
The documentation provides a list of all the standard libraries which can be defined in the Eclispe built-path but I am under the impression the endpoint API is not part of it.
Would be great to understand if there is a standard library I could add to make this work like "Google Cloud Platform Libraries -> Cloud Datastore"
Alternatively I could use another authentication method like an API keys but I could not figure out which service account needs which API key to authenticate against my end point.
Thank you
I am trying to compile the sample example provided here with Java 8 but Eclipse cannot find the library.
I was expecting to activate a standard Google Cloud library to get the example running and then figure out the authentication against the Google Cloud Endpoint.

Related

How can I get id_token of gcloud using java instead of gcloud command

Can someone give me a piece of java code to get id_token on GCP using google account?
I've got a restful api endpoint service deployed on GCP to test. I can use my google account to get the id_token using command "gcloud config config-helper"(e.g. id_token: eyJadhI6....). This id_token is then placed in the header as the value of authorization. The REST request is fired as expected. But I need to do the same using Java instead of from console command line to get a valid id_token.
I encourage you to use one of the Google-provided client libraries (SDKs).
These are open-sourced and tested by Google and provide you with a much better platform for your development.
See:
https://cloud.google.com/apis/docs/cloud-client-libraries
https://github.com/googleapis/google-cloud-java
and:
https://github.com/googleapis/google-cloud-java#authentication
Using these SDKs you will avoid the complexity in navigating your way through the underlying REST APIs directly.
Couple of useful tricks|pointers:
Google APIs Explorer enables you to use the REST APIs from the browser
If you append --log-http to any gcloud command, the REST calls are logged.
NB There are 2 flavors of APIs (API Client Libraries and Cloud Client Libraries) see explanation. The Cloud Client Libraries are more modern, are idiomatic and are preferred if you're mostly using GCP.
HTH!

How to generate oauth token, client id and secret using gcloud or Google Cloud Java SDK

I have a very big task, I need to automate the process of creating Dialogflow agents, for which I need to first create a Google project, which I have figured out using Java SDK, then I need to get client id and client secret to get an access token to send it to Dialogflow agent creation REST call, I just don't know how to generate a Oauth credentials for a project.
I'm using Java, Play framework. I even got success creating service account but just can't figured out how to generate Oauth creds.
Well, after doing some more research, turns out there is no API or there is no way to create oauth credentials clientId and client_sercret / client_secret.json file programmatically. One has to create it from google console itself.
There are several ways to call a Google API (Dialogflow) one is via a service account.
You mention you have already created a Service Account.
Next you can automate the credential creation via the Google API Client Library for Java as mention here.
Finally just call the Google API
You can find the full documentation of DialogFlow for Java here

Registering eddystone beacon without OAuth Playground

I have been using the Eddystone platform for a few months now, and things are working well. However, when registering new beacons, I am finding myself needing to open Google's OAuth 2.0 Playground and all the steps associated with it in order to send a PUT request that contains my new base64-encoded Eddystone-UID.
Is there any way to register beacons with Eddystone without having to use the OAuth 2.0 Playground? I would like to build a standalone desktop Java application that automates this process, so any Java tips would be much appreciated.
Thanks!
Yes, you can use Google's APIs to do an OAuth 2.0 sign in and then make the web service calls to the Proximity Beacon API. The key part is setting up OAuth 2.0 on your Java client. These two documents might help:
Using OAuth 2.0 to Access Google APIs
API Client Library for Java
Once you have an OAuth token, you can call the APIs as described below. You may have already done this if you are using the playground.
Getting Started with the Proximity Beacon API
Proximity Beacon API Overview

How to implement OAuth in Bitrix for third party Applications?

I am currently using Bitrix24 for HR management and task management.
Since it provides an option to integrate third party applications with it, I am stuck in how to implement OAuth for my application with Bitrix.
I went through documentation provided by Bitrix24 but it uses php code.
Is there any sample JAVA code available for OAuth implementation?
Unfortunately havent seen any examples on other that PHP languages, but
if you are already experienced with Java it should not be a problem.
In case you are working with bitrix24 cloud edition - you need to
1) create application for marketplace using you partner account and obtain secret key and application id
2) send this secret key and application id from your application written on any language and receive
3) receive request token and refresh_token and use them to access rest api provided by Bitrix24 https://training.bitrix24.com/rest_help/
more details on what kind of request you need to do: https://training.bitrix24.com/rest_help/oauth/examles.php
hope this help you.
You can use API like this for JAVA
I am adding LEADS from the API, and updating the same LEAD
to add the LEAD:-
Method: POST
URL:-
https://.bitrix24.com/rest/crm.lead.add
Parameters:-
{"fields[TITLE]":"LEAD_TITLE","auth":"AUTH_TOKEN"}
It will add the new LEAD in you Bitrix Dashboard.

Can I run locally and debug a Web App that uses Google API's? [GWT+GAE]

I'm working on a web-app using Google App Engine with GWT, and I need to use Google API's (Google Calendar, Documents and so...).
As I know, I must configure a domain with Google to set my domain as callback of an OAuth Authentication. Am I right?
If so, am I forced to deploy on GAE to test? I mean, I can't run locally because my localhost can't be a valid callback.
Do you know any way to debug locally even using Google API's?
I have recommended to config a DynDNS, but isn't a solution in short term (incompatible router)...
If you use AuthSub instead I don't think you need to register a domain. The user just need a google account.
I have in the past used AuthSub together with Google Docs/Spreadsheet APIs on GAE and also been able to test it locally.
I can unfortunately not give you my code and exact solution (it was a while ago). But one of the samples I used extensively to base my code on was the FetcherServlet, check this code out:
http://code.google.com/p/google-app-engine-samples/source/browse/trunk/retrieving-gdata-feeds-java/src/com/google/appengine/demo/web/FetcherServlet.java?r=122
Also, I guess you might already have read this page (but their FetcherServlet uses OAuth, not AuthSub), so maybe just use it for some background info:
http://code.google.com/appengine/articles/java/retrieving_gdata_feeds.html

Categories