Click here to Skip to main content
15,909,518 members
Home / Discussions / C#
   

C#

 
AnswerRe: PredicateBuilder Question Pin
Dave Kreskowiak1-Jul-23 4:23
mveDave Kreskowiak1-Jul-23 4:23 
GeneralRe: PredicateBuilder Question Pin
Kevin Marois1-Jul-23 8:21
professionalKevin Marois1-Jul-23 8:21 
AnswerRe: PredicateBuilder Question Pin
BillWoodruff1-Jul-23 9:54
professionalBillWoodruff1-Jul-23 9:54 
AnswerRe: PredicateBuilder Question Pin
James Curran5-Jul-23 10:41
James Curran5-Jul-23 10:41 
QuestionUnable to Receive data from Cobas e411 Serial Port Pin
Member 1493027227-Jun-23 22:20
Member 1493027227-Jun-23 22:20 
AnswerRe: Unable to Receive data from Cobas e411 Serial Port Pin
Richard MacCutchan27-Jun-23 23:08
mveRichard MacCutchan27-Jun-23 23:08 
AnswerRe: Unable to Receive data from Cobas e411 Serial Port Pin
OriginalGriff27-Jun-23 23:38
mveOriginalGriff27-Jun-23 23:38 
AnswerRe: Unable to Receive data from Cobas e411 Serial Port Pin
Ralf Meier28-Jun-23 0:43
mveRalf Meier28-Jun-23 0:43 
AnswerRe: Unable to Receive data from Cobas e411 Serial Port Pin
jschell28-Jun-23 6:08
jschell28-Jun-23 6:08 
GeneralRe: Unable to Receive data from Cobas e411 Serial Port Pin
Member 1493027228-Jun-23 6:21
Member 1493027228-Jun-23 6:21 
AnswerRe: Unable to Receive data from Cobas e411 Serial Port Pin
Gerry Schmitz28-Jun-23 6:51
mveGerry Schmitz28-Jun-23 6:51 
QuestionGoogle PeopleAPI & HttpListener Redirect URI Pin
Kevin Marois22-Jun-23 10:03
professionalKevin Marois22-Jun-23 10:03 
AnswerRe: Google PeopleAPI & HttpListener Redirect URI Pin
jschell23-Jun-23 10:45
jschell23-Jun-23 10:45 
GeneralRe: Google PeopleAPI & HttpListener Redirect URI Pin
Kevin Marois23-Jun-23 12:18
professionalKevin Marois23-Jun-23 12:18 
GeneralRe: Google PeopleAPI & HttpListener Redirect URI Pin
Richard Andrew x6425-Jun-23 11:44
professionalRichard Andrew x6425-Jun-23 11:44 
GeneralRe: Google PeopleAPI & HttpListener Redirect URI Pin
Kevin Marois25-Jun-23 17:41
professionalKevin Marois25-Jun-23 17:41 
GeneralRe: Google PeopleAPI & HttpListener Redirect URI Pin
jschell26-Jun-23 5:31
jschell26-Jun-23 5:31 
GeneralRe: Google PeopleAPI & HttpListener Redirect URI Pin
Kevin Marois26-Jun-23 8:20
professionalKevin Marois26-Jun-23 8:20 
GeneralRe: Google PeopleAPI & HttpListener Redirect URI Pin
Kevin Marois26-Jun-23 16:19
professionalKevin Marois26-Jun-23 16:19 
Update on this. Here's some things I found...

First, on the Google People API Console[^], we had a Web Application set up, which I now think is wrong. We want a Desktop App since this is a WPF app.

One key difference is that the Web Application page shows fields for Authorized redirect URIs[^]. This one has '<https: 127.0.0.1="">' in it.

The Desktop App [^] does NOT have redirect URIs.

But when I downloaded the credentials JSON, it contains
"redirect_uris":["http://localhost"]}

Then, in my code I have
public async Task TryAuthorizeAsync()
{
    // code ommitted
    ...

    // HTTOListener callback URI.
    string listenerURI = $"https://{IPAddress.Loopback}:{GetRandomUnusedPort()}/"; //==== Listener callback on random port

    // Auth callback URL
    string callbackURI = "<a href="http://localhost">http://localhost</a>";  //==== SET TO LOCALHOST
    RaiseStatusChanged($"listening on {listenerURI}");

    try
    {
        _callbackListener.Prefixes.Add(listenerURI);
        _callbackListener.Start();
    }
    catch (Exception e)
    {
        throw e;
    }

    // Create the authorization request.
    var authorizationRequest = $"{AuthorizationEndpoint}?response_type=code&" +
                                $"scope=openid%20profile&" +
                                $"redirect_uri={Uri.EscapeDataString(callbackURI)}&" + //=====  Uses default from downloade JSON
                                $"client_id={ClientID}&" +
                                $"state={state}&" +
                                $"code_challenge={codeChallenge}&" +
                                $"code_challenge_method={CODE_CHALLENEGE_METHOD}";

    // Opens request in the default browser
    Process.Start(authorizationRequest);

    bool success = false;

    // Wait for the auth authorization response.
    await Task.Run(() =>
    {
        // Begin waiting for context. Call the ListenerCallback when context is recieved
        var callback = new AsyncCallback(result => ListenerCallback(result, state, codeVerifier, listenerURI));  // ==== Listening on random port
        IAsyncResult context2 = _callbackListener.BeginGetContext(callback, _callbackListener);

        if (HANDLE_TIMEOUT)
        {
            success = context2.AsyncWaitHandle.WaitOne(RESPONSE_TIMEOUT, true);
        }
    });
}
But it still doesn't work. The auth page comes up and when I select a Google account it attempts to redirect but fails with Site can't be reached. Localhost refused to connect[^]

Here's the thing, this is Google's sample code[^] and it appears that they're doing the same thing. I can't see their console, but their docs show a Loopback IP address (Redirect URI)[^]

So, it seems that for a web app it's required, and for a desktop app it's defaulting to localhost. Yet I can's seem to make this work.
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.

GeneralRe: Google PeopleAPI & HttpListener Redirect URI Pin
jschell27-Jun-23 4:48
jschell27-Jun-23 4:48 
General[UPDATE] - Google PeopleAPI & HttpListener Redirect URI Pin
Kevin Marois27-Jun-23 6:01
professionalKevin Marois27-Jun-23 6:01 
GeneralRe: [UPDATE] - Google PeopleAPI & HttpListener Redirect URI Pin
jschell28-Jun-23 5:54
jschell28-Jun-23 5:54 
QuestionThreading related naming and usage of const Pin
HobbyProggy20-Jun-23 5:04
professionalHobbyProggy20-Jun-23 5:04 
AnswerRe: Threading related naming and usage of const Pin
Richard Deeming20-Jun-23 6:05
mveRichard Deeming20-Jun-23 6:05 
GeneralRe: Threading related naming and usage of const Pin
HobbyProggy20-Jun-23 23:02
professionalHobbyProggy20-Jun-23 23:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.