Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8813817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:57:17+00:00 2026-06-14T03:57:17+00:00

I am trying to implement OAuth 2.0 implicit grant from java desktop client application

  • 0

I am trying to implement OAuth 2.0 implicit grant from java desktop client application using SkyDrive REST API. I use the following code:

Desktop.getDesktop().browse(new URL(st.toString()).toURI());
JOptionPane.showMessageDialog(null, "Press ok to continue once you have authenticated.");

my code opens web browser and ask users to signin and then SkyDrive sends access token to the browser url in the following form:

https://login.live.com/oauth20_desktop.srf?lc=1033#access_token=EwAwAq1DBAAUlbRW.....

What I want to do is to read this access token from my java program.
I tried to read httpconnection from console:

HttpURLConnection con = (HttpURLConnection) url.openConnection();
BufferedReader reader = new BufferedReader( new InputStreamReader(url.openStream()));
while(reader.readLine()!=null){
System.out.println(reader.readLine());

but it seems that java httpurlconnection does not handle javascript response. It replies:

<html dir="..... Windows Live ID requires JavaScript to sign in. This web browser either does not support JavaScript, or scripts are being blocked......<body onload="evt_LoginHostMobile_onload(event);">

So, Is there any way to retrieve the access token directly from java?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T03:57:18+00:00Added an answer on June 14, 2026 at 3:57 am

    I had the same problem. After hours of brainstorming, I have finally found a solution. I use the JavaFX library to create a WebView. Then you can intercept location change.

    import java.net.MalformedURLException;
    import java.net.URL;
    import java.util.HashMap;
    import java.util.Map;
    
    import javafx.application.Application;
    import javafx.event.EventHandler;
    import javafx.scene.Scene;
    import javafx.scene.layout.BorderPane;
    import javafx.scene.web.WebEngine;
    import javafx.scene.web.WebEvent;
    import javafx.scene.web.WebView;
    import javafx.stage.Stage;
    
    public class Authenticate extends Application {
    
        static final String APP_ID = "...";
        static final String REDIRECT_URL = "https://login.live.com/oauth20_desktop.srf";
        static final String RESPONSE_TYPE = "token";
        static final String SCOPE = "wl.signin%20wl.offline_access";
    
        private Scene scene;
    
        @Override
        public void start(final Stage stage) throws Exception {
            final String url = "https://login.live.com/oauth20_authorize.srf?client_id="+APP_ID
                    +"&scope="+SCOPE+"&response_type="+RESPONSE_TYPE+"&oauth_callback=oob&redirect_uri="+REDIRECT_URL;
            BorderPane borderPane = new BorderPane();
    
            WebView browser = new WebView();
            WebEngine webEngine = browser.getEngine();
    
            webEngine.load(url);
            borderPane.setCenter(browser);
    
            webEngine.setOnStatusChanged(new EventHandler<WebEvent<String>>() {
                public void handle(WebEvent<String> event) {
                    if (event.getSource() instanceof WebEngine) {
                        WebEngine we = (WebEngine) event.getSource();
                        String location = we.getLocation();
                        if (location.startsWith(REDIRECT_URL) && location.contains("access_token")) {
                            try {
                                URL url = new URL(location);
                                String[] params = url.getRef().split("&");
                                Map<String, String> map = new HashMap<String, String>();
                                for (String param : params) {
                                    String name = param.split("=")[0];
                                    String value = param.split("=")[1];
                                    map.put(name, value);
                                }
                                System.out.println("The access token: "+map.get("access_token"));
                                stage.hide();
                            } catch (MalformedURLException e) {
                                e.printStackTrace();
                            }
                        }
                    }
                }
            });
    
            // create scene
            stage.setTitle("Skydrive");
            scene = new Scene(borderPane, 750, 500);
            stage.setScene(scene);
            stage.show();
        }
    
        public static void main(String[] args) {
            launch(args);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to implement Twitter's OAuth into my Code Igniter web application at
I'm trying to implement Google's OAuth 2.0 authentication for a web server application. I
we are trying to implement linkedin into our application and we want to use
I am working from this reference , and trying to implement the OAuth protocol
I'm trying to implement a Login with Facebook using the Open Graph API. So
I'm trying to implement a Google App Engine Go application that will be using
I'm trying to implement Twitter login for my web application. I use scribe to
So I'm trying to re-implement the OAuth1 OAuthConsumer and OAuthServiceProvider samples from DotNetOpenAuth using
I'm trying to implement OAuth for Google, Twitter, Yahoo etc. on Android using the
I'm trying to implement sign in with Google using Oauth (using DotNetOpenAuth). I need

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.