Below documentation has details for accessing various GCP resources but not GCP project. I am interested in listing all the labels of a GCP project using .net API.
https://cloud.google.com/dotnet/docs/reference
Any references/links will be helpful
Found the solution.
Google.Cloud.ResourceManager.V3.ProjectsClient projectsClient = await Google.Cloud.ResourceManager.V3.ProjectsClient.CreateAsync();
Google.Cloud.ResourceManager.V3.Project response = await projectsClient.GetProjectAsync("projects/83446985491");
//response.Labels;
Source:
https://cloud.google.com/dotnet/docs/reference/Google.Cloud.ResourceManager.V3/latest/Google.Cloud.ResourceManager.V3.Projects.ProjectsClient
As mentioned in this SO thread, Currently, it's not possible to list all labels within a GCP project.
In Addition, There is an existing feature request, you can star this feature request and add Me too in the thread. This will bring more attention to the request as more users request support for it but there's no guarantee when it will be implemented.
Related
This question already has an answer here:
Legacy People API has not been used in project
(1 answer)
Closed 1 year ago.
Google API is active but give error ;
Legacy People API has not been used in project before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/legacypeople.googleapis.com/overview?project= then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.
You don't need to install any other APIs like Google Drive API, Google Sheets API or other except Google+ API,
The error is coming because of "passport-google-oauth": "^1.0.0"
Just change the version "passport-google-oauth": "^1.0.0" to "passport-google-oauth": "^2.0.0" and remove node_modules and package.lock.json file and run "npm i"
That's it
Before the Google+ API Shutdown on March 7, 2019, the people.get and people.getOpenIdConnect methods were available for requesting a person’s profile.
To avoid breaking existing integrations with these methods supporting sign-in, a new minimal implementation only returns basic fields necessary for that functionality, such as name and email address, if authorized by the user. The Legacy People API is where these methods will remain available for existing callers at the existing HTTP endpoints.
The Legacy People API serves a limited new implementation of the legacy Google+ API people.get and people.getOpenIdConnect methods necessary for maintaining sign-in functionality. It is available to existing callers of the original methods that haven't migrated to recommended replacements such as Google Sign-in or Google People API at the time of the Google+ API shutdown.
enter link description here
Thanks
In this case, I'm facing the same issue. This is what I've done to fix it.
Situation:
NodeJS ver 8
"passport-google-oauth": "^1.0.0"
Using Google+ API as Google Sign-in
When I run the apps and click Sign in with Google, what happened then?
Server error
Error log: Legacy People API has not been used in project "xxxx" before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/legacypeople.googleapis.com/overview?project=xxxx then retry.
How I solve it?
Go to Google Console
Click on Google+ API under Social APIs, then click Enable API
Click on Google Drive API under G Suite, then click Enable API
Click on Google Sheets API under G Suite, then click Enable API
Update "passport-google-oauth": "^1.0.0" to "passport-google-oauth": "^2.0.0"
in package.json
remove package-lock.json and node_modules folder (to ensure everything is clear)
run this command : npm install
It works now!
Note: my previous code still using profile._json.image.url to get profile image. Actually, this response was not there anymore. So I delete this code.
Goodbye Google+
Thank you Google People API.
Enabling the Google Contacts API and the Google+ API fixed this issue for me.
Hi I recently stumbeled on the same issue. As explained by Ilan Laloum, Google+ API as been decommissionned completely for new projects.
I found that Google People API works in a similar way. The following example is based on the Bookshelf tutorial in GCP. Source code can be seen here: https://github.com/GoogleCloudPlatform/golang-samples/tree/appengine/go111/cloudsql/getting-started/bookshelf (branch appengine/go111/cloudsql)
import people "google.golang.org/api/people/v1"
...
// retrieves the profile of the user associated with the provided OAuth token
func fetchProfile(ctx context.Context, tok *oauth2.Token) (*people.Person, error) {
peopleService, err := people.NewService(ctx, option.WithTokenSource(bookshelf.OAuthConfig.TokenSource(ctx, tok)))
if err != nil {
return nil, err
}
return peopleService.People.Get("people/me").
PersonFields("names,coverPhotos,emailAddresses").
Do()
}
This method needs a context and a OAuth token, just like Google+ API used to. The peopleService is initialized in a similar fashion.
The peopleService.People.Get("people/me") prepares a query that fetches the profile of the connected user. Then PersonFields("names,coverPhotos,emailAddresses") is a filter on profile fields. This part of the request is mandatory. Eventually Do() will execute the request.
This issue can be fixed using the passport-google-token
npm install passport-google-token
const GoogleStrategy = require('passport-google-token').Strategy;
// Google OAuth Strategy
passport.use('googleToken', new GoogleStrategy({
clientID: CLIENT_ID,
clientSecret: CLIENT_SECRET
}, async (accessToken, refreshToken, profile, done) => {
try {
console.log('creating a new user')
const newUser = new User({
google: {
id: profile.id,
email: profile.emails[0].value
}
});
await newUser.save();
done(null, newUser);
} catch (error) {
done(error, false, error.message);
}
}));
I was also having the same issue but with my Rails app. So I resolved it by upgrading the omniauth gems by running bundle update devise omniauth omniauth-google-oauth2 in terminal.
I also faced the same issue. This issue may occur for using the old library, enable the google people Api for your project, and download the library as per your php version from this link and integrate it.
Background information:
I'm trying to create a PoC for Google Cloud Vision API using their .NET library.
What I have done:
Create a simple console apps with the following code for Vision API.
GoogleCredential credential = GoogleCredential.FromFile(ConfigurationManager.AppSettings["GoogleCredentialFile"]);
Grpc.Core.Channel channel = new Grpc.Core.Channel(Google.Cloud.Vision.V1.ImageAnnotatorClient.DefaultEndpoint.ToString(), credential.ToChannelCredentials());
var client = Google.Cloud.Vision.V1.ImageAnnotatorClient.Create(channel);
var image = Google.Cloud.Vision.V1.Image.FromFile(#"C:\Users\u065340\Documents\sample.jpg");
var response = client.DetectLabels(image);
foreach (var annotation in response)
{
if (annotation.Description != null)
result = annotation.Description;
}
Problem:
The line client.DetectLabels(image) gets stuck for a long time before ultimately throwing the error Deadline Exceeded.
My code sits behind a corporate proxy, but I have validated that it is not blocking internet access because I can call https://vision.googleapis.com/$discovery/rest?version=v1 from the same apps and get its JSON response just fine.
Any suggestions?
After digging around through github issues related to proxies as suggested by Jon Skeet, I found that Google Cloud Client APIs can be generally divided into 2 categories (Ref: here): REST-based HTTP 1.1 with JSON and gRPC.
For APIs associated as REST-based, there should be no issue with proxies. The problem starts to appear when we are using gRPC-based APIs such as Google Cloud Vision and Google Speech. In gRPC, we need to explicitly provide our proxy server information.
For those using Java Client, it seems we still can't set proxy properly because it will eventually be ignored, and causing the Deadline Exceeded error. This issue is already well known and can be found at here and further traced into here.
The Google team has determined that it is indeed a bug, and the status remains Open.
As for C# Client, we can set proxy information using gRPC Environment Variables which is documented in here. The code is Environment.SetEnvironmentVariable("http_proxy", <your_proxy_server>);
After I set the http_proxy environment variable pointing to my proxy server, all is well again. I get the expected output "This API needs Billing Account".
Many thanks to Jon Skeet for pointing me in the right direction :D
Using Information via Microsoft.Azure.Management.Fluent I'm trying to get to information about Web Jobs. I'm able to use it to get information about Web Apps, Service Buses, Resource Groups, App Services, etc.
But I haven't been able to find a way to get to the Web Job level. In Azure the Web Jobs are located at the level
https://ms.portal.azure.com/#resource/subscriptions/{SubId}/resourceGroups/{ApServiceName}/providers/Microsoft.Web/sites/{ApServiceName}/webJobs
Using Microsoft.Azure.Management.Fluent I haven't been able to find a way to get to the Web Jobs level. Is this possible via the Microsoft.Azure.Management.Fluent?
Is this possible via the Microsoft.Azure.Management.Fluent?
Based on my exerpience, No. According to Azure SDK source code, it seems that there is no way to get the WebJob level.
If we want to get WebJob level, Azure supplies the WebJob API for us to operate on WebJob. About authorization for the WebJob API, we could refer to the this blog.
I had a need to execute some management API code for WebJobs and found that it is now possible, although it's not easy to find it in the API documentation.
You can do it by installing the Microsoft.Azure.Management.AppService.Fluent package (I think it's also possible to do it the non-fluent management SDK too, although I didn't try this).
Getting access to the methods for managing a WebJob can be done like this:
using Microsoft.Azure.Management.Fluent;
using Microsoft.Azure.Management.ResourceManager.Fluent;
using Microsoft.Azure.Management.ResourceManager.Fluent.Authentication;
class MyWebJobsManagementClass
{
public async Task DoSomeWebJobsManagement()
{
var jobs = await Azure
.Authenticate() // See the docs for how to authenticate with this SDK
.WithSubscription("your-subscription-id")
.AppServices
.Inner
.WebApps
.ListWebJobsWithHttpMessagesAsync("resource-group-name", "app-service-name")
}
}
It's through the non-obvious AppServices.Inner that you can get a reference to an IWebAppsOperations instance which then lets you perform quite a few operations on the WebJobs, including starting and stopping them.
Authentication Side note
If you're looking for a way to authenticate with Azure.Identity, instead of the file based credentials approach they used to use with these older SDKs, then there is a way to achieve this even though it's not supported "out-the-box".
There's a GitHub repo which contains an example of how to achieve this. I think it's by one of the developers on the Microsoft team, but isn't officially supported by Microsoft. There is no NuGet package for it and they recommend just copying the bits you need.
I actually found that the code in that sample repo was overly complex for my needs and in my case that all I needed was this. Note, I've copied this from my F# project without testing it, so I might have made a mistake in the conversion to C#, but hopefully it's close enough that you get the idea.
class AzureIdentityFluentCredentialAdapter : AzureCredentials
{
public AzureIdentityFluentCredentialAdapter(string tenantId)
: base(default(DeviceCredentialInformation), tenantId, AzureEnvironment.AzureGlobalCloud)
{
}
public override Task ProcessHttpRequestAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
var creds = DefaultAzureCredential() // Use the new Azure.Identity library to get access tokens
var accessToken = await creds.GetTokenAsync(
new TokenRequestContent(new [] { "https://management.azure.com/.default" }),
cancellationToken);
return await TokenCredentials(accessToken.Token)
.ProcessHttpRequestAsync(request, cancellationToken);
}
}
This example doesn't do any token caching, but for my purposes I wasn't too bothered about this. It's also hardcoded the scope that I request the token for because I knew I was only going to be using this with the Azure management API.
I have successfully integrated my company's system with DocuSign using DocuSign's SOAP API. I can send, check status and retrieve Envelopes through the SOAP interface.
I have read that the preferred method of getting Envelope status is through an event. Unfortunately I haven't had any luck finding an example of this.
I found some documentation about it HERE.
Has anyone used this way of event / notification from DocuSign that would help point me in the right direction?
There are examples of it on DocuSign's own Lithium forums (which will be made read-only soon) in PHP for example. They're pretty easy to setup, you just need a server listening for the events with the rights ports open and you just add the eventNotification element to your request. You've referenced the SOAP api guide, which the sample PHP code below shows how to implement. There's also a version available for REST API.
You can download DocuSign's SOAP SDK out of GitHub and there's sample PHP project ready of out of the box for you to start modifying and adding in eventNotifications.
// Notifications
$eventNoti = new EventNotification();
$eventNoti->URL = 'http://myurl.com/docusign/updateDocStatus'.$env_id.'/';
$eventNoti->LoggingEnabled = "TRUE";
// Important Stuff below
$envEvent = new EnvelopeEvent();
$envEvent->EnvelopeEventStatusCode = "Completed"; // <---------- Fires on "Completed" only
$envEvent->IncludeDocuments = "TRUE";
$eventNoti->EnvelopeEvents = array($envEvent); // <------------ Add multiple EnvelopeEvent's
$envInfo->EventNotification = $eventNoti;
This link is where the above code is referenced from, along with further discussion that might help.
Another option is to use the DocuSign Connect module to push events to your external listener. The main difference between DocuSign Connect and the eventNotification is that eventNotification is per envelope, Connect is account wide and or user-wide.
Currently I am using Codeplex's Facebook Developer Toolkit version 2 for my ASP.net Facebook application. I would like to be able to send notifications to a user's Inbox or wall of the application and was wondering what are the available functions to do that? If not in the API, then please provide example functions from the main Facebook library. This will help immensely. Thanks!
After a brief search I found an example of sending notifications using the toolkit:
facebook.Components.FacebookService fs
= new facebook.Components.FacebookService();
fs.ApplicationKey =
ConfigurationManager.AppSettings["APIKey"];
fs.Secret =
ConfigurationManager.AppSettings["Secret"];
string sessionKey =
dict["facebook_session_key"];
fs.SessionKey = sessionKey; fs.uid =
long.Parse(member.FacebookId);
fs.notifications.send(member.FacebookId,
"notification message");
(from: http://facebooktoolkit.codeplex.com/Thread/View.aspx?ThreadId=49876)
After looking through the Codeplex source it's clear that this sends a user-to-user notification, and therefore requires an active user session of the sender.
Codeplex does not appear to support app-to-user notifications which do not require a session, but adding this feature would be trivial. Add a type variable to the send method and set it accordingly based on the API documentation here: http://wiki.developers.facebook.com/index.php/Notifications.send
The source code for the notifications.send method in the Codeplex Developer Toolkit is here:
http://facebooktoolkit.codeplex.com/SourceControl/changeset/view/28656#233852
Please keep in mind that the Codeplex developer toolkit source code has not been updated in over 3 months. This means that it does not support many new Facebook API features and changes. You may want to browse the client library wiki page to find a library that is more up to date: http://wiki.developers.facebook.com/index.php/Client_Libraries