question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AuthorizationCodeInstalledApp should not use java.awt.Desktop

See original GitHub issue

AuthorizationCodeInstalledApp uses java.awt.Deskopt to start an external webbrowser for user authentication. However, this renders authentication impossible in JavaFX applications as the application just freezes and no external browser window is opened. In JavaFX, for example, WebView might be preferable over an external browser. In general, it is preferable to not have to pull in awt classes when running JavaFX code.

One way around this would be to pass a handler to AuthorizationCodeInstalledApp to allow the caller to decide how to browse a URL.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
hanslovskycommented, Jan 19, 2019

@mavrovgeorgi https://github.com/googleapis/google-oauth-java-client/pull/182 introduced a Browser interface that allows the caller to use a different way to open a browser than the standard awt way. I suggest you have a closer look at the changes in the PR.

0reactions
poppitocommented, Oct 3, 2019

Further to what @hanslovsky has suggested - you can do something like this (code is in kotlin)

    val browser = AuthorizationCodeInstalledApp.Browser {
            if (it != null) {
                val intent = Intent(Intent.ACTION_VIEW)
                intent.data = Uri.parse(it)
                startActivity(intent)
            }
        }

And this should be done on a background thread:

            AuthorizationCodeInstalledApp(
                flow, LocalServerReceiver()
            , browser).authorize("user")
Read more comments on GitHub >

github_iconTop Results From Across the Web

authorization - Unable to resolve java.awt.Desktop in ...
java.lang.NoClassDefFoundError: Failed resolution of: Ljava/awt/Desktop; at com.google.api.client.extensions.java6.auth.oauth2.
Read more >
Uses of Package java.awt.desktop (Java SE 15 & JDK 15)
Contains all of the classes for creating user interfaces and for painting graphics and images. · Provides interfaces and classes for interaction with...
Read more >
com.google.api.client.extensions.java6.auth.oauth2 ...
AuthorizationCodeInstalledApp maven / gradle build tool code. ... Preconditions; import java.awt.Desktop; import java.awt.Desktop.Action; import java.io.
Read more >
Using OAuth 2.0 with the Google API Client Library for Java
Purpose: This document explains how to use the GoogleCredential utility class to do OAuth 2.0 authorization with Google services.
Read more >
Java Examples for java.awt.Desktop.Action - Javatips.net
This java examples will help you to understand the usage of java.awt. ... isDesktopSupported()) { System.err.println("Desktop is not supported (fatal)"); ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found