private static async Task QueryBynderUsingOAuth(IBynderClient client)
        {
            using var waitForToken = new WaitForToken();
            using var listener     = new UrlHttpListener("http://localhost:8888/", waitForToken);

            Browser.Launch(client.GetOAuthService().GetAuthorisationUrl("state example", "offline asset:read collection:read"));
            waitForToken.WaitHandle.WaitOne(50000);

            if (waitForToken.Success)
            {
                client.GetOAuthService().GetAccessTokenAsync(waitForToken.Token, "offline asset:read collection:read").Wait();
                await QueryBynder(client);
            }
        }
Example #2
0
 private async Task AuthenticateWithOAuth2Async(bool useClientCredentials)
 {
     if (useClientCredentials)
     {
         await _bynderClient.GetOAuthService().GetAccessTokenAsync();
     }
     else
     {
         Browser.Launch(_bynderClient.GetOAuthService().GetAuthorisationUrl("state example"));
         Console.WriteLine("Insert the code: ");
         var code = Console.ReadLine();
         await _bynderClient.GetOAuthService().GetAccessTokenAsync(code);
     }
 }