Skip to content
This repository has been archived by the owner on Apr 9, 2019. It is now read-only.

Add support for Microsoft accounts #24

Open
delthas opened this issue Jan 10, 2017 · 19 comments
Open

Add support for Microsoft accounts #24

delthas opened this issue Jan 10, 2017 · 19 comments
Assignees

Comments

@delthas
Copy link
Owner

delthas commented Jan 10, 2017

Some users would like to use this library with Microsoft accounts (#23), maybe add that in the future.

@MrPowerGamerBR
Copy link

There was a code on how to login in a Microsoft account at samczsun/Skype4J#128 , but the message was deleted (and the user account doesn't exist anymore)

Maybe @Manevolent still has his fix for Skype4J?

@delthas
Copy link
Owner Author

delthas commented Jan 10, 2017

I think I know how to do this, the process is detailed here: https://github.com/msndevs/protocol-docs/wiki/Authentication#microsoft-accounts

@Manevolent
Copy link

Manevolent commented Jan 10, 2017

I do!

https://gist.github.com/Manevolent/1c6bc379c10c1e50358e8f2e2356fef7

That's what I've been using since the mentioned ticket, I made some minor changes to the original poster's source but this has been working fine for me.

JSONObject object = LiveLoginHelper.getXTokenObject(username, password);
String skypeToken = object.getString("skypetoken");
String skypeId = object.getString("skypeid");

MSFTSkypeClient client = new MSFTSkypeClient.Builder(skypeToken, skypeId)
            .withLogger(Logger.getGlobal())
            .withExceptionHandler(handler)
            .withAllResources().build();

client.login();
...

The changes I made just sanitize the XML email/password, and acknowledge the "skypeId" returned in my code block above, which is very important if you're using a migrated (skypename -> email) account, which I have been using. I've been having some issues with the auth sticking, though, and sometimes my bot will randomly log out and stay that way until I address it. Until I figure that out, I'll probably wait to make a pull request.

Also, maven deps:

        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>20160810</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.5</version>
        </dependency>

Also, JSoup is used, too.

@klingan
Copy link

klingan commented May 21, 2017

@Manevolent since we are 4 months later, were you able to resolve your auth issues? A pull request would still come in handy 💩

@simk0024
Copy link

I think this should be put in higher priority, as all skype account are forced to link with Microsoft now...

@ruha9005
Copy link

ruha9005 commented Jun 9, 2017

May be it can help:
https://skpy.t.allofti.me/protocol/login.html

@ItsGravix
Copy link

@Manevolent I get this:
org.json.JSONException: JSONObject["wst:RequestedSecurityToken"] not found.

@Erezbiox1
Copy link

Exception in thread "main" java.lang.RuntimeException: java.lang.ArrayIndexOutOfBoundsException: 1

@Erezbiox1
Copy link

Can anyone please help me out on this?

@Erezbiox1
Copy link

Simply removing the line from the gist seems to work...
weird.
the line is "this.cookies.put(setCookie[0], setCookie[1]);"

@metasonic
Copy link

@Erezbiox1 any chance you got a fork of this with the fix applied for logging in with email and password or provide a short guide on how to get this working? Thank you!

@delthas
Copy link
Owner Author

delthas commented Nov 7, 2017

Hello, I will look into this this week. Sorry for the long delay. To be honest I wasn't sure if anyone needed this at all.

@Erezbiox1
Copy link

@metasonic Yes, here's the gist,
and here's the required libraries:
image
Do note, this only works with Skype4J

@delthas delthas self-assigned this Nov 8, 2017
@metasonic
Copy link

metasonic commented Nov 9, 2017

@Erezbiox1 Thanks a lot for that, integrated it locally with Skype4J, tested it and it works, but having issues using the packaged Skype4J in another project.
Getting the following error:
Exception in thread "main" java.lang.NoSuchMethodError: org.json.JSONArray.forEach(Ljava/util/function/Consumer;)V at com.samczsun.skype4j.internal.client.MSFTSkypeClient$LiveLoginHelper.parsePayload(MSFTSkypeClient.java:206) at com.samczsun.skype4j.internal.client.MSFTSkypeClient$LiveLoginHelper.getXTokenObject(MSFTSkypeClient.java:267) at com.samczsun.skype4j.SkypeBuilder.build(SkypeBuilder.java:134)

After adding the class to the project made the following change to SkypeBuilder
`public Skype build() {
if (resources.isEmpty()) {
throw new IllegalArgumentException("No resources selected");
}
if (password != null && !username.contains("@")) {
return new FullClient(username, password, resources, customLogger, errorHandlers);
} else if (chatId != null && !username.contains("@")) {
return new GuestClient(username, chatId, resources, customLogger, errorHandlers);
} else if (username.contains("@")) {
JSONObject object = null;
try {
object = MSFTSkypeClient.LiveLoginHelper.getXTokenObject(username, password);
} catch (Exception e) {
throw new IllegalArgumentException("Bad response");
}

        String skypeToken = object.getString("skypetoken");
        String skypeId = object.getString("skypeid");
        return new MSFTSkypeClient(skypeToken, skypeId,
                resources, customLogger,
                errorHandlers);
    } else {
        throw new IllegalArgumentException("No chat specified");
    }`

@metasonic
Copy link

@delthas the framework you buit is the perfect plug and play not stress that you need for Skype, so, I for one love it and would like to see it grow

@delthas
Copy link
Owner Author

delthas commented Nov 10, 2017

Hello. Good news! I have added support for Microsoft accounts to JavaSkype. There are no API changes besides the fact that logging with a Microsoft account (e.g. [email protected]) should work.

Please update to version 1.0.22 (I have copied the <dependency> block below). Open a new issue for any problem you may have, but do send me the debug logs when opening an issue (simply call setDebug to create a debug file).

    <dependency>       
           <groupId>fr.delthas</groupId>
           <artifactId>javaskype</artifactId>
           <version>1.0.22</version>
    </dependency>

@indeterminatus
Copy link

@delthas thanks for tackling this issue in such a speedy fashion now :). There still seems to be a problem when using a Skype account that has been linked to a Microsoft account (as is the case for me). I can provide two debug logs (one for Skype login, one for Microsoft Account login) and would be quite willing to help resolve this -- kindly contact me via e-mail.

@metasonic
Copy link

@delthas thanks a lot for this!

@metasonic
Copy link

After doing the following steps skype.connect(); remains stuck
Steps:

  1. create a new skype object
  2. initialize connection (skype.connect();)
  3. get the groups you are into (skype.getGroups(); )
  4. disconnect
    *Notice that after doing this a few times the script will remain stuck at the skype.connect part
    PS. sometimes it gives the following error:
    Exception in thread "Skype-Receiver-Thread" java.lang.IllegalArgumentException at fr.delthas.skype.NotifConnector.parseEntity(NotifConnector.java:792) at fr.delthas.skype.NotifConnector.updateThread(NotifConnector.java:738) at fr.delthas.skype.NotifConnector.processPacket(NotifConnector.java:254) at fr.delthas.skype.NotifConnector.lambda$new$0(NotifConnector.java:73) at java.lang.Thread.run(Thread.java:745)

Debug logs
https://www.dropbox.com/s/5mql7cyxs9na9tj/debug3.txt?dl=0
https://www.dropbox.com/s/e6uzyrjos7gfefl/debug2.txt?dl=1

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

10 participants