Git Product home page Git Product logo

gmusic.api's Introduction

PROJECT IS DEPREACTED look at https://github.com/FelixGail/gplaymusic instead

#gmusic.api: an unofficial Java API for Google Play Music

This project needs help! I currently have way to little time to maintain this my self so ANY help would be appreciated!

The project is not supported nor endorsed by Google.

Respect Google in your use of the API. Use common sense (protocol compliance, reasonable load, etc) and don't ruin the fun for everyone else.

This project is a port of (Simon Weber's great work) of a port (Taylor Finnell's port to .NET) written in Java.

Feature Overview:

  • Getting library information:

    • all song metadata
    • all user playlist titles and ids
    • songs from a specific playlist
  • Song downloading

The api currently only implement read methods (get and retrieval) but more methods could be implemented in time either by me or you:)

This project is dual licensed under GNU GPL, Version 3 and MIT.

Copyright 2012 [Jens Kristian Villadsen] (http://www.genuswillehadus.net). [Baron Keith Hall, Sapien Mobile, LLC] (http://www.sapienmobile.com).

gmusic.api's People

Contributors

bparry02 avatar jkiddo avatar xnickmx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gmusic.api's Issues

License

Hi,

I have forked your project and am considering, assuming it still works, using it with a project I am working on (a Chrome extension). You have your project marked GPL v3. Did you pick this for a specific reason or just throw a dart at a list of licenses? I'd greatly prefer you to change to MIT license OR dual license (GPL3 or MIT). I don't plan to every commercialize my extension (who would buy it?) but GPL3 just rubs me the wrong way.

Thanks,
Kevin

HttpURLConnection NumberFormatException

Just trying to get the example up and running on Android and falling over at the first hurdle. I know little about ClientLogin/OAuth/OpenID but understand that because this is not an official api we have to use the now deprecated ClientLogin. My problem comes down to this right now... a NumberFormat Exception deep in the stack on HttpURLConnection.openConnection()

URL url = new URL("https://www.google.com/accounts/ClientLogin");
HttpURLConnection connection = (HttpURLConnection)url.openConnection();

Any ideas what's going on? Here's the stack trace

Integer.parseInt(String, int) line: not available
Integer.(String) line: not available
InetAddressCachePolicy.() line: not available
InetAddress$Cache.getPolicy() line: not available
InetAddress$Cache.put(String, Object) line: not available
InetAddress.cacheInitIfNeeded() line: not available
InetAddress.cacheAddress(String, Object, boolean) line: not available
InetAddress.getAddressFromNameService(String, InetAddress) line: not available
InetAddress.getLocalHost() line: not available
SeedGenerator$1.run() line: not available
AccessController.doPrivileged(PrivilegedAction) line: not available [native method]
SeedGenerator.getSystemEntropy() line: not available
SecureRandom$SeederHolder.() line: not available
SecureRandom.engineNextBytes(byte[]) line: not available
SecureRandom.nextBytes(byte[]) line: not available
SecureRandom.next(int) line: not available
SecureRandom(Random).nextInt() line: not available
DefaultSSLContextImpl(SSLContextImpl).engineInit(KeyManager[], TrustManager[], SecureRandom) line: not available
DefaultSSLContextImpl.() line: not available
NativeConstructorAccessorImpl.newInstance0(Constructor, Object[]) line: not available [native method]
NativeConstructorAccessorImpl.newInstance(Object[]) line: not available
DelegatingConstructorAccessorImpl.newInstance(Object[]) line: not available
Constructor.newInstance(Object...) line: not available
Class.newInstance0() line: not available
Class.newInstance() line: not available
Provider$Service.newInstance(Object) line: not available
GetInstance.getInstance(Provider$Service, Class) line: not available
GetInstance.getInstance(String, Class, String) line: not available
SSLContext.getInstance(String) line: not available
SSLContext.getDefault() line: not available
SSLSocketFactory.getDefault() line: not available
HttpsURLConnection.getDefaultSSLSocketFactory() line: not available
HttpsURLConnectionImpl(HttpsURLConnection).(URL) line: not available
HttpsURLConnectionImpl.(URL, Proxy, Handler) line: not available
Handler.openConnection(URL, Proxy) line: not available
Handler.openConnection(URL) line: not available
URL.openConnection() line: not available

Invalid Credentials on login

Re-writing a python app in Java where I used to use gmusic api.

Very simple use, I'm just looking to list songs in my library and play from urls, so the only functionality I need is getAllSongs() and Song.getURL()

Trying to initialise a GoogleMusicAPI with a very simple login is not working for me. I'm just doing so far:

GoogleMusicAPI musicAPI = new GoogleMusicAPI();
        try {
            musicAPI.login(GoogleMediaUsername, GoogleMediaPassword);
        } catch (Exception ex) {
            System.out.println(ex);
        }

I'm getting the Invalis Credentials Exception with the message "gmusic.api.impl.InvalidCredentialsException: Provided credentials: '***********@googlemail.com' and '*******' where insufficient" (redacted, not actually asterixs)

Not sure what I'm doing wrong because the login credentials are correct and I'm trying to peice together the correct procedure from mathod names as there's obv no documentation or comments in the API.

Can you assist at all?

Google Music All Access

If you subscribe to All Access and add an album or tracks to your library, the search function returns not a "url" entry but "urls". Taking the first url in the returned array, the MediaPlayer starts but then ends after less than a second.

Obviously this is new from Google so not expecting anyone to have thought about this yet, but wanted to get the dialogue going....

I tried to login using following method but the response code given was 200, but response contains error

I tried to login using following method but the response code given was 200 :

public static final boolean login(final Context context, final String authToken) {
if (!TextUtils.isEmpty(authToken)) {

     final SimpleForm form = new SimpleForm().close();

     GoogleMusicApi.setAuthorizationHeader(authToken);

     String response = mHttpClient.post(context, "https://play.google.com/music/listen?hl=en&u=0", new  ByteArrayEntity(form.toString().getBytes()), form.getContentType());

    Log.d(TAG, "response = " + response);
    Log.d(TAG, "mHttpClient.getResponseCode() " + mHttpClient.getResponseCode());

    return mHttpClient.getResponseCode() == HttpStatus.SC_OK;

  } else {
    return false;
  }

}

and I got response like this :

12-11 17:55:03.785: D/com.android.gm.api.GoogleMusicApi(24744): response =
Google Play Music#gb{font:13px/27px Arial,sans-serif;height:30px}#gbz,#gbg{position:absolute;white-space:nowrap;top:0;height:30px;z-index:1000}#gbz{left:0;padding-left:4px}#gbg{right:0;padding-right:5px}#gbs{background:transparent;position:absolute;top:-999px;visibility:hidden;z-index:998;right:0}.gbto #gbs{background:#fff}#gbx3,#gbx4{background-color:#2d2d2d;background-image:none;background-image:none;background-position:0 -138px;background-repeat:repeat-x;border-bottom:1px solid #000;font-size:24px;height:29px;height:30px;opacity:1;filter:alpha(opacity=100);position:absolute;top:0;width:100%;z-index:990}#gbx3{left:0}#gbx4{right:0}#gbb{position:relative}#gbbw{left:0;position:absolute;top:30px;width:100%}.gbtcb{position:absolute;visibility:hidden}#gbz .gbtcb{right:0}#gbg .gbtcb{left:0}.gbxx{display:none !important}.gbxo{opacity:0 !important;filter:alpha(opacity=0) !important}.gbm{position:absolute;z-index:999;top:-999px;visibility:hidden;text-align:left;border:1px solid #bebebe;background:#fff;-moz-box-shadow:-1px 1px 1px rgba(0,0,0,.2);-webkit-box-shadow:0 2px 4px rgba(0,0,0,.2);box-shadow:0 2px 4px rgba(0,0,0,.2)}.gbrtl .gbm{-moz-box-shadow:1px 1px 1px rgba(0,0,0,.2)}.gbto .gbm,.gbto #gbs{top:29px;visibility:visible}#gbz .gbm{left:0}#gbg .gbm{right:0}.gbxms{background-color:#ccc;display:block;position:absolute;z-index:1;top:-1px;left:-2px;right:-2px;bottom:-2px;opacity:.4;-moz-border-radius:3px;filter:progid:DXImageTransform.Microsoft.Blur(pixelradius=5);opacity:1;top:-2px;left:-5px;right:5px;bottom:4px;-ms-filter:"progid:DXImageTransform.Microsoft.Blur(pixelradius=5)";opacity:1\0/;top:-4px\0/;left:-6px\0/;right:5px\0/;bottom:4px\0/}.gbma{position:relative;top:-1px;border-style:solid dashed dashed;border-color:transparent;border-top-color:#c0c0c0;display:-moz-inline-box;display:inline-block;font-size:0;height:0;line-height:0;width:0;border-width:3px 3px 0;padding-top:1px;left:4px}#gbztms1,#gbi4m1,#gbi4s,#gbi4t{zoom:1}.gbtc,.gbmc,.gbmcc{display:block;list-style:none;margin:0;padding:0}.gbmc{background:#fff;padding:10px 0;position:relative;z-index:2;zoom:1}.gbt{position:relative;display:-moz-inline-box;display:inline-block;line-height:27px;padding:0;vertical-align:top}.gbt{display:inline}.gbto{box-shadow:0 2px 4px rgba(0,0,0,.2);-moz-box-shadow:0 2px 4px rgba(0,0,0,.2);-webkit-box-shadow:0 2px 4px rgba(0,0,0,.2)}.gbzt,.gbgt{cursor:pointer;display:block;text-decoration:none !important}span#gbg6,span#gbg4{cursor:default}.gbts{border-left:1px solid transparent;border-right:1px solid transparent;display:block;display:inline-block;padding:0 5px;position:relative;z-index:1000}.gbts{display:inline}.gbzt .gbts{display:inline;zoom:1}.gbto .gbts{background:#fff;border-color:#bebebe;color:#36c;padding-bottom:1px;padding-top:2px}.gbz0l .gbts{color:#fff;font-weight:bold}.gbtsa{padding-right:9px}#gbz .gbzt,#gbz .gbgt,#gbg .gbgt{color:#ccc!important}.gbtb2{display:block;border-top:2px solid transparent}.gbto .gbzt .gbtb2,.gbto .gbgt .gbtb2{border-top-width:0}.gbtb .gbts{background:url(//ssl.gstatic.com/gb/images/b_8d5afc09.png);_background:url(//ssl.g

how to resolve this issue?

filtered response :
<HTML>
<HEAD>
<TITLE>Forbidden</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Forbidden&</H1>
<H2>Error 403</H2>
</BODY>
</HTML>

Getting 404 errors

I'm getting 404 errors thrown by any call of dispatchGet()

I'm using a logged in api client.

Any thoughts? Is there known breakage right now?

Authentication Question

I'm integrating your library with my current app which already uses the Android AccountManager for authentication with an App Engine (GAE) server.

The authtoken obtained for the GAE is fetched as follows

    accountManager.getAuthToken(account, "ah", false, new GetAuthTokenCallback(), null);

Where "ah" is the authTokenType for App Engine. Other types are "youtube", "finance" etc for the different apis.

So here's my question...
Is it possible to obtain a token this way for gmusic.api and avoid the need to user to enter their password? If so, what authTokenType should be used?

Reusing saved instances of Song doesn't work anymore

Hi,

I finally found some time to work on my project using this api, repairing it from the last changes of google.
When I getAllSongs(...), I serialize them and save them into a file so that I don't have to download it all again next time I open the program. It used to work like a charm until now. I always receive a 404 when I reuse saved data.

Do you have any idea how to fix this ?

ps: I only serialize the Songs, I don't serialize the api.

Regards

android - GmHttpClient post() returns null

For authentication purpose I have copied an AsyncTask named GoogleAuthTask from #5.

public class GoogleAuthTask extends AsyncTask<String, Void, Boolean> {

private Activity mActivity;

public GoogleAuthTask(Activity activity) {
mActivity = activity;
}

@OverRide
protected Boolean doInBackground(String... params) {
boolean success = false;
try {
String authToken = GoogleAuthUtil.getToken(mActivity, params[0],
"sj");

    if (!TextUtils.isEmpty(authToken)) {
        GoogleMusicApi.createInstance(mActivity);

        success = GoogleMusicApi.login(mActivity, authToken);

        if (!success)
            GoogleAuthUtil.invalidateToken(mActivity, authToken); 
    }
} catch (UserRecoverableAuthException e) {
    mActivity.startActivityForResult(e.getIntent(), 1001);
    e.printStackTrace();
} catch (IOException e) {
    e.printStackTrace();
} catch (GoogleAuthException e) {
    e.printStackTrace();
}

return success;

}
}

From this AsyncTask there is a call to static login() method on GoogleMusicApi class.

public static final boolean login(Context context, String authToken)
{
if(!TextUtils.isEmpty(authToken))
{
SimpleForm form = new SimpleForm().close();
GoogleMusicApi.setAuthorizationHeader(authToken);
mHttpClient.post(context, "https://play.google.com/music/listen?hl=en&u=0", new ByteArrayEntity(form.toString().getBytes()), form.getContentType());
return true;
}
else
return false;
}

If I go into this method & print response of post() call, it returns null. Same is the case for any call to this post(). For example if I make a call to getAllSongs(), it has post() call internally which again returns null.

public static final ArrayList getAllSongs(Context context) throws JSONException
{
return getSongs(context, "");
}

public static final ArrayList getSongs(Context context, String continuationToken) throws JSONException
{

SimpleForm form = new SimpleForm();
form.addField("json", "{\"continuationToken\":\"" + continuationToken + "\"}");
form.close();

String response = mHttpClient.post(context, "https://play.google.com/music/services/loadalltracks?u=0&xt=" + getXtCookieValue(), new ByteArrayEntity(form.toString().getBytes()), form.getContentType());

JSONObject jsonObject = new JSONObject(response);
Playlist playlist = new Playlist().fromJsonObject(jsonObject);

ArrayList<Song> chunkedSongList = new ArrayList<Song>();
chunkedSongList.addAll(playlist.getPlaylist());

if(!TextUtils.isEmpty(playlist.getContinuationToken()))
    chunkedSongList.addAll(getSongs(context, playlist.getContinuationToken()));

return chunkedSongList;

}

Since response of post() call is null always, I get following stacktrace when calling getAllSongs():

12-04 14:33:36.640: E/AndroidRuntime(29132): FATAL EXCEPTION: AsyncTask #1
12-04 14:33:36.640: E/AndroidRuntime(29132): java.lang.RuntimeException: An error occured while executing doInBackground() 12-04 14:33:36.640: E/AndroidRuntime(29132): at android.os.AsyncTask$3.done(AsyncTask.java:278) 12-04 14:33:36.640: E/AndroidRuntime(29132): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273) 12-04 14:33:36.640: E/AndroidRuntime(29132): at java.util.concurrent.FutureTask.setException(FutureTask.java:124) 12-04 14:33:36.640: E/AndroidRuntime(29132): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307) 12-04 14:33:36.640: E/AndroidRuntime(29132): at java.util.concurrent.FutureTask.run(FutureTask.java:137) 12-04 14:33:36.640: E/AndroidRuntime(29132): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208) 12-04 14:33:36.640: E/AndroidRuntime(29132): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076) 12-04 14:33:36.640: E/AndroidRuntime(29132): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569) 12-04 14:33:36.640: E/AndroidRuntime(29132): at java.lang.Thread.run(Thread.java:856) 12-04 14:33:36.640: E/AndroidRuntime(29132): Caused by: java.lang.NullPointerException 12-04 14:33:36.640: E/AndroidRuntime(29132): at org.json.JSONTokener.nextCleanInternal(JSONTokener.java:116) 12-04 14:33:36.640: E/AndroidRuntime(29132): at org.json.JSONTokener.nextValue(JSONTokener.java:94) 12-04 14:33:36.640: E/AndroidRuntime(29132): at org.json.JSONObject.(JSONObject.java:154) 12-04 14:33:36.640: E/AndroidRuntime(29132): at org.json.JSONObject.(JSONObject.java:171) 12-04 14:33:36.640: E/AndroidRuntime(29132): at com.android.gm.api.GoogleMusicApi.getSongs(GoogleMusicApi.java:146) 12-04 14:33:36.640: E/AndroidRuntime(29132): at com.android.gm.api.GoogleMusicApi.getAllSongs(GoogleMusicApi.java:134) 12-04 14:33:36.640: E/AndroidRuntime(29132): at com.example.testgmusic.MainActivity$GoogleAuthTask.doInBackground(MainActivity.java:100) 12-04 14:33:36.640: E/AndroidRuntime(29132): at com.example.testgmusic.MainActivity$GoogleAuthTask.doInBackground(MainActivity.java:1) 12-04 14:33:36.640: E/AndroidRuntime(29132): at android.os.AsyncTask$2.call(AsyncTask.java:264) 12-04 14:33:36.640: E/AndroidRuntime(29132): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305) 12-04 14:33:36.640: E/AndroidRuntime(29132): ... 5 more

Search changed

Search results are now....

{"subscriptionTrack":[],"subscriptionAlbum":[],"subscriptionArtist":[]}

Someone else has seen this and reported on simonweber's repo too

JsonSyntaxException while getting all the tracks (getAllTracks())

Hi,

I'm developing a prog to play google music. It was working fine until recently. Even my backup versions are not working anymore. I suppose the it could come from the google interface that has change ?

So, I'm getting all the tracks from my google music account after login myself.

As I said it was working fine.
Here are the details of the error. If you have any idea where it can come from or how to fix it, it would be great :)

Btw this API is awesome :)

Thank you in advance,
John

com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:176)
at com.google.gson.Gson.fromJson(Gson.java:803)
at com.google.gson.Gson.fromJson(Gson.java:768)
at com.google.gson.Gson.fromJson(Gson.java:717)
at com.google.gson.Gson.fromJson(Gson.java:689)
at gmusic.api.comm.JSON.deserialize(JSON.java:24)
at gmusic.api.impl.GoogleSkyJamAPI.getTracks(GoogleSkyJamAPI.java:59)
at gmusic.api.impl.GoogleSkyJamAPI.getAllTracks(GoogleSkyJamAPI.java:51)
at layer_manager.ApiManager.getAllTrack(ApiManager.java:139)
at gui_launcher.Main_guiLauncher.newLibraryConnected(Main_guiLauncher.java:392)
at gui_launcher.Main_guiLauncher.createNewLib(Main_guiLauncher.java:354)
at gui_launcher.NewLib.loadMyLib(NewLib.java:183)
at gui_launcher.NewLib.actionPerformed(NewLib.java:155)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

Login fails with 404, requires OAuth2

The login URL is returning a 404. Currently it is referencing https://www.google.com/accounts/ClientLogin.

Google states,

Important: ClientLogin has been officially deprecated since April 20, 2012 and is now no longer available. Requests to ClientLogin will fail with a HTTP 404 response. We encourage you to migrate to OAuth 2.0 as soon as possible.

I can try to take a look in the future if I have spare time.

Failed to get the Songs

I have used this library in my code and when I try to use the search api like

QueryResults results = GoogleMusicApi.search(MainActivity.this, "rock");

It gave me this error message

Authentication error: Unable to respond to any of these challenges: {googlelogin=WWW-Authenticate: GoogleLogin realm="https://www.google.com/accounts/ClientLogin", service="sj"}

Search problem on Android

I have things working within an Android app and can stream music after fetching all songs.

However, GoogleMusicApi.search(context, "Coldplay") fails with a nullpointerexception on

return new QueryResults().fromJsonObject(jsonObject
.optJSONObject("results"));

because the json response is as follows (ie. has no results)

{"success":false, "reloadXsrf": true}

What am I missing?

Upload Question

Hi , I have read a Simon Weber upload documentation and I saw his "api.py , protocol.py ecc"
(I have not a pyrhon skill). I saw that you have not implementation upload api so sorry for my question, I understand that i do an HttpsConnection so:

  • method Post
  • url https://android.clients.google.com/upsj/upauth
  • headers field : 'Cookie': SID=sid_cookie'
  • headers field 'Content-Type': 'application/x-google-protobuf'
  • body the Google's Protocol Buffers, a binary data format whit adress and hostname.

All this just to authenticate my device on Google Music.
Now I make tis step:

  • I download protobuf-2.4.1.tar.bz2 , compiled and imported in my project

  • I used a metadata.proto (Simon Weber) file to create a Metadata.java class with
    protoc -I=$SRC_DIR --java_out=$DST_DIR $SRC_DIR/ametadata.proto

  • I wrote a simple method to test with your library

    
    public final synchronized String myDispatchPost(URI address, FormBuilder form) throws IOException, URISyntaxException
    {
        HttpsURLConnection connection = myPrepareConnection(address, true, "POST");
        if(!Strings.isNullOrEmpty(form.getContentType()))
        {
            connection.setRequestProperty("Content-Type", form.getContentType());
        }
        connection.connect();
        connection.getOutputStream().write(form.getBytes());
        connection.getInputStream();
        if(connection.getResponseCode() != 200)
        {
            throw new IllegalStateException("Statuscode " + connection.getResponseCode() + " not supported");
        }
    
        String response = IOUtils.toString(connection.getInputStream());
    
        setCookie(connection);
    
        if(!isStartup)
        {
            return response;
        }
        return mySetupAuthentication(response);
    }
    private HttpsURLConnection myPrepareConnection(URI address, boolean output, String method) throws URISyntaxException, IOException
    {
        HttpsURLConnection connection = (HttpsURLConnection) address.toURL().openConnection();
        connection.setRequestProperty("Accept-Encoding", "gzip,deflate");
        connection.setRequestMethod(method);
        connection.setDoOutput(output);
        if(SID != null)
        {
            connection.setRequestProperty(COOKIE_SID_KEY, String.format(COOKIE_SID_VALUE, SID));
        }
        return connection;
    }
    private String mySetupAuthentication(String response) throws IOException, URISyntaxException
    {
        isStartup = false;
        SID = Util.extractSIDToken(response);
        FormBuilder myFormBuilder= FormBuilder.getEmpty();
        myFormBuilder.setContentType("application/x-google-protobuf");
        myFormBuilder.addAuth();
        return myDispatchPost(new URI(HTTPS_PLAY_GOOGLE_UPSJ_UPATH), myFormBuilder);
    }

This add FormBuilder.java


public void addAuth(){
        UploadAuth uploadAuth= Util.createUploadAuth();
        try {
            uploadAuth.writeTo(outputStream);
            outputStream.close();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

and in Util.java


static String extractSIDToken(String response) throws ParseException
    {

        // Pattern pattern = Pattern.compile("Auth=(?(.*?))$", Pattern.CASE_INSENSITIVE);
        // String auth = pattern.matcher(EntityUtils.toString(response.getEntity())).group();

        int startIndex = response.indexOf("SID=") + "SID=".length();
        int endIndex = response.indexOf("\n", startIndex);

        return response.substring(startIndex, endIndex).trim();
    }
    static  UploadAuth createUploadAuth(){
        UploadAuth uploadAuth=  Metadata.UploadAuth.newBuilder().setAddress("30:78:9h:cy:81:2f").setHostname("dommy-x").build();
        return uploadAuth;
    }

I get always HTTP response code: 400 Bad Request , I seem to have forgotten nothing

Any suggestions?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.