Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

save auth to avoid users to enter the code from a text message #32

Open
winagain opened this issue Jan 18, 2015 · 3 comments
Open

save auth to avoid users to enter the code from a text message #32

winagain opened this issue Jan 18, 2015 · 3 comments

Comments

@winagain
Copy link

hello , everyone , is there anyone able to save the auth to a file successfully ?

Method 01 : save the whole apiState (source : #22)
result : not success

Method 02 : using AuthExportAuthorization (source : https://core.telegram.org/api/datacenter , Authorization Transfer)
result : not success
TLExportedAuthorization authExported = api.doRpcCall(new TLRequestAuthExportAuthorization(destDC)) ;

TLBytes authBytes = authExported.getByte() ; // ==> can't be java.io.NotSerializ

bytes[] authBytes = authExported.getByte().getDate() ; // ==> AUTH_BYTES_INVALID using it in AuthImportAuthorization

@voleon
Copy link

voleon commented Jan 19, 2015

I have success with Method01. I used implementation of AbsApiState from telegram-bot (https://github.com/ex3ndr/telegram-bot/blob/master/app/src/main/java/org/telegram/bot/engine/MemoryApiState.java).
I've added interface Serializable to MemoryApiState class and inner class ConnectionInfo. And then just serialize apiState to file on auth, and deserialize from file when application starts.

@winagain
Copy link
Author

voleon , thank you very much , i do it successfully. Your comment give me some light to continue in Method 1 and the missing part is need to re-connect by :

    connections.put(1, new ConnectionInfo[]{
            new ConnectionInfo(1, 0, isTest ? "149.154.167.xx" : "149.154.167.xx", 443)
    });     

@Chaki1306
Copy link

Hello, help me.
Where serialize apiState?(In which place?)
Can you give an example?
I have an error(SecurityException) when deserialize from file when application starts

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

No branches or pull requests

3 participants