|
|
I am looking at this Google API WPF OAuth Example[^]
I understand most of what it's doing. In userinfoCall() it displays the Google user's info
Making API Call to Userinfo...
{
"sub": "",
"name": "Kevin Marois",
"given_name": "Kevin",
"family_name": "Marois",
"locale": "en"
}
What I need is to get the user's contacts. I've been searching & playing with this all day but I can't figure out how to do this.
In theory, theory and practice are the same. But in practice, they never are.”
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
|
|
|
|
|
I very much doubt if you can: I'd class my contacts list as "personal information" and I'd be pretty unhappy if any site I logged into using Google had access to them or my calendar.
There is also GDPR which would almost certainly apply, and Google isn't going to ignore that!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
You, as the user, authorize it via an OAuth window. We already had this functionality in out app, then Google changed their Auth process. I'm just trying to upddate the app
See this[^]
I just can't figure out how to integrate that into their sample code
In theory, theory and practice are the same. But in practice, they never are.”
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
|
|
|
|
|
|
Certainly looks like that should answer the OPs question.
As a side note looking at that very quickly I didn't see any mention of what happens if the reader doesn't have permission to view those. Seems like that would be a very relevant error case. Certainly something that a developer should test.
|
|
|
|
|
jschell wrote: I didn't see any mention of what happens if the reader doesn't have permission to view those. I think that may be dealt with in the section about getting set up to use the People API.
|
|
|
|
|
I saw that already. I can't figure out how to integrate that first bit into their sample
In theory, theory and practice are the same. But in practice, they never are.”
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
|
|
|
|
|
I'm afraid that using the Google API's is not the easiest thing in the world, IMHO. You need to follow the link to the setup section and start there. It's a good few years since I set up my account (which has since been deleted) so i'm afraid I can't offer any insights.
|
|
|
|
|
OK, thanks anyway
In theory, theory and practice are the same. But in practice, they never are.”
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
|
|
|
|
|
Just curious - have you used any non trivial API ever that was easy? Perhaps not just initially but including support?
Myself I was used 'bitly' which seemed pretty easy except that they throttled using a HTTP 500 error with no other error message. So no way to know if there was a problem on their end or if one had just reached the throttle limit. Noting of course that HTTP 429 exists for exactly this reason.
|
|
|
|
|
Once I figured out the rules it was easy. But, as with most things, the learning curve was a bit steep.
|
|
|
|
|
I was right: What data Google shares
Important: Sign in with Google doesn’t share your Google Account password.
When you use Sign in with Google to access a third-party app or service, Google only shares the following information associated with your Google Account:
Your name
Your email address
Your profile picture
This data is only shared after you give permission. If you want to use Sign in with Google, you can't exclude any of these pieces of data.
In addition to your name, email address, and profile picture, the third party might request further access to some of your Google Account data. You might be able to get contact access if you asked for it when you tried to use OAuth as a added permission, but even that's dodgy with GDPR as it includes other people's personal info so technically you might need permission from each individual in my contacts in order to get them.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Yeah ... "contacts" are "personal" information; just what your spammer / hacker is looking for.
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
I need to open the default browser with Process.Start(), and I need to know if the user has cancelled or closed the process/browser.
I can detect a cancel via the callback URL, but I can't seem to get Exited to work.
public class Program
{
public static void Main(string[] args)
{
var proc = Process.Start("www.codeproject.com");
proc.Exited += Program_Exited;
proc.WaitForExit();
Console.ReadLine();
}
private static void Program_Exited(object sender, EventArgs e)
{
}
}
What's the right way to handle this?
In theory, theory and practice are the same. But in practice, they never are.”
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
modified 6-Jun-23 20:00pm.
|
|
|
|
|
|
Thanks. I set EnableRaisingEvents and it fires the event, however it fires right away as soon as Process.Start() is called. I'm hoping to handle the user closing the default browser.
I saw that page earlier. I have one question on that.
I want to open the default browser and wait for the user to close it. In this code I would have to specifically specify what browser I want.
public class Program
{
private static Process myProcess;
private static TaskCompletionSource eventHandled;
public static void Main(string[] args)
{
StartProcess();
Console.ReadLine();
}
private static async Task StartProcess()
{
eventHandled = new TaskCompletionSource();
using (myProcess = new Process())
{
try
{
myProcess.StartInfo.FileName = "chrome";
myProcess.EnableRaisingEvents = true;
myProcess.Exited += new EventHandler(myProcess_Exited);
myProcess.Start();
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
await Task.WhenAny(eventHandled.Task, Task.Delay(30000));
}
}
private static void myProcess_Exited(object sender, System.EventArgs e)
{
Console.WriteLine("Process exited");
eventHandled.TrySetResult(true);
}
}
Setting
"myProcess.StartInfo.FileName = "www.codeproject.com";"
throws an exception because that's looking for a exe to run.
In theory, theory and practice are the same. But in practice, they never are.”
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
|
|
|
|
|
Kevin Marois wrote:
myProcess.StartInfo.FileName = "www.codeproject.com"; Because you're not specifying the protocol, so Windows has no way of knowing that you want to open a website rather than a DOS-style COM application called www.codeproject .
Specify the URL you want to open instead:
myProcess.StartInfo.FileName = "https://www.codeproject.com/";
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Kevin Marois wrote: I can detect a cancel via the callback URL
You probably have some more failure cases there.
For example what happens if the user does nothing with the site? Just leaves it up?
What happens if the site is down?
Can the site reject their input (whatever it is?)
What happens if the url is invalid?
|
|
|
|
|
I've fumbled and bumbled my way though being able to read an rtsp stream, I've learned how to capture frames and detect changes between frames (motion) any frame in which i have detected motion i have learned how to save it as a jpg file. now comes the time I'm wanting to present codeproject.ai with the jpg file and wait for a response from it. i see the example of doing that but in html/javascript, i'm writing in c#, i was wondering if anyone has an example of sending the jpg and waiting for a response in c#. if not I'm looking at restsharp as the tool to use. anyone know a better tool to use ?
|
|
|
|
|
As this is a question about the CodeProject AI capability, the best place to ask this question is in the CodeProject.AI Discussions[^] forum.
|
|
|
|
|
As he's a spammer[^], the best place to post his "question" would be a different site.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Here are the constraints that I am facing
Can only use SQL Server
Cannot use Entity Framework or Dapper
Can only use .NET Framework (can't use any Python or JS)
What I am working on is a project for a factory I work for is that I am digitizing our quality inspections, of which there are numerous. The first step is that I created some models to that are used to create a Quality Inspection plan, which are here below:
public class QualityInspection
{
public int Id;
public string Name;
public double Frequency;
public List<InspectionSection> Sections;
}
public class InspectionSection
{
public int Id;
public int InspectionId;
public string Name;
public List<InspectionPoint> Points;
}
public class InspectionPoint
{
public int Id;
public int SectionId;
public string Name;
public List<NonConformance> InspectionResults;
}
public class NonConformance
{
public int Id;
public string Name;
public List<NonConformanceLevel> Level;
}
public enum NonConformanceLevel
{
None,
Minor,
Major
}
This is an example of a dummy inspections plan:
QualityInspection inspection = new QualityInspection()
{
Id = 1,
Name = "FgInspection",
Frequency = 2,
Sections.AddRange(new[]
{
new InspectionSection() {
Id = 1,
InspectionId = 1,
Name = "Packaging",
Points.AddRange(new[]
{
new InspectionPoint()
{
Id = 1,
SectionId = 1,
Name = "Seals",
InspectionResults.AddRange(new[]
{
new NonConformance() {Id = 1, Name = "Torn", Level = NonConformanceLevel.Minor},
new NonConformance() {Id = 2, Name = "None", Level = NonConformanceLevel.None})
});
},
new InspectionPoint()
{
Id = 2,
SectionId = 1,
Name = "Dates",
InspectionResults.AddRange(new[]
{
new NonConformance() {Id = 3, Name = "Smudged", Level = NonConformanceLevel.Minor},
new NonConformance() {Id = 4, Name = "None", Level = NonConformanceLevel.None})
});
}
});
}
}),
});
};
To clarify, saving this inspection is NOT THE ISSUE. This is able to be saved to a SQL table without a problem.
Let's use the "Packaging" section as an example here. The user pulls up this Inspection to fill out. The page displays Two dropdowns: one for "Seals" Inspection Point and one for "Dates" Inspection Point. The "Seals" dropdown displays the two NonConformances as options to select. The user hits a Submit button to submit the choices for the dropdown.
This is where I run into a problem. This Inspection Plan is created by a USER in a different portion of the app. As such, I don't have a table so save the "Seals" or "Dates" data, because the user created those fields when they created the inspection plan. In essence I am trying to save the RESULTS of an a user created inspection plan.
|
|
|
|
|
That's your "logical view". You said SQL "table"; I see 4-5 tables. In other words, there is nothing stopping you from "adding inspections" later.
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
There is nothing stopping me from saving another inspection later. That isn't the problem. My user creates this inspection, and the inspection is then saved to the SQL tables. A form is then generated from these Inspections for factory operators to fill out later.
For example, if there are two inspection points, then two drop down options on the form will be generated, one for each point. The problem is saving the data from those dropdowns, because those dropdowns are generated from the inspection, created by another user, so I don't have a SQL table that can map to the data from the dropdowns - since a user created those fields, not me.
|
|
|
|