-
Notifications
You must be signed in to change notification settings - Fork 0
/
AuthenticationManager.java
50 lines (43 loc) · 1 KB
/
AuthenticationManager.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import java.io.IOException;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
public class AuthenticationManager {
//Get google Auth key
public static String getGoogleAuthKey(String email,String password)
{
try{
Document doc = Jsoup.connect(Constants.GOOGLE_LOGIN_URL)
.data("accountType","GOOGLE",
"Email",email,
"Passwd",password,
"service","reader",
"source", "PrivateReader-v1")
.timeout(4000)
.post();
return doc.body().text();
}catch(Exception ex)
{
ex.printStackTrace();
return "NULL";
}
}
//Get token
public static String getGoogleToken(String authkey)
{
try
{
Document doc = Jsoup.connect(Constants.TOKEN_URL)
.header("Authorization",Constants.AUTHPARAMS + authkey)
.timeout(4000)
.get();
// Retrieve the response token
String _TOKEN = doc.body().text();
return _TOKEN;
}
catch(Exception ex)
{
ex.printStackTrace();
return null;
}
}
}