gpt4 book ai didi

安卓:谷歌认证+Ubertoken

转载 作者:太空狗 更新时间:2023-10-29 15:09:29 25 4
gpt4 key购买 nike

好吧,我放弃了。任何人都有使用 Google 的 IssueAuthToken 和 MergeSession 对某些没有官方 API 访问权限的 Google 服务进行身份验证的经验吗?在本例中,我尝试获取 Google 书签(来自 google.com/bookmarks)。

我使用 getAuthToken 获取 SID 和 LSID,效果很好。然后我打电话

Uri ISSUE_AUTH_TOKEN_URL = Uri.parse("https://accounts.google.com/IssueAuthToken?service=bookmarks&Session=false");

String url = ISSUE_AUTH_TOKEN_URL.buildUpon()
.appendQueryParameter("SID", sid)
.appendQueryParameter("LSID", lsid)
.build().toString();

我收到“ubertoken”。

然后我对 MergeSession 执行 GET,这就是所有错误的地方:

String url2 = "https://accounts.google.com/MergeSession?source=chrome&uberauth="+uberToken+"&service=bookmarks&continue=https%3A%2F%2Fwww.google.com%2Fbookmarks%2F";
HttpGet getCookies = new HttpGet(url2);

查看 getCookies 的 header ,我没有看到我应该看到的额外 cookie,而且我还看到了类似 X-Frame-Options: DENY 的内容。

帮助(请)!

最佳答案

好的 friend 们,我们开始吧。截至 2013 年 8 月,以上内容似乎现在至少偶尔会不可靠/损坏。这就是我现在正在做的事情并且它似乎有效。它首先尝试上述方法,如果失败,则继续执行方法 #2。

  final Account acct = am.getAccountsByType("com.google")[acctid];
final String tokenType = "weblogin:service=bookmarks&continue=https://www.google.com/bookmarks/";

am.getAuthToken(acct, tokenType, null, this, new AccountManagerCallback<Bundle>() {
@Override
public void run(AccountManagerFuture<Bundle> future) {
try {
final String accessToken = future.getResult().getString(AccountManager.KEY_AUTHTOKEN);
if (accessToken.contains("WILL_NOT_SIGN_IN")) {
am.getAuthToken(acct, "SID", null, MainActivity.this, new AccountManagerCallback<Bundle>() {
@Override
public void run(AccountManagerFuture<Bundle> future) {
try {
sid = future.getResult().getString(AccountManager.KEY_AUTHTOKEN);
} catch (OperationCanceledException e) {
finish();
} catch (Exception e) {
e.printStackTrace();
}

am.getAuthToken(acct, "LSID", null, MainActivity.this, new AccountManagerCallback<Bundle>() {
@Override
public void run(AccountManagerFuture<Bundle> future) {
try {
lsid = future.getResult().getString(AccountManager.KEY_AUTHTOKEN);
} catch (OperationCanceledException e) {
finish();
} catch (Exception e) {
e.printStackTrace();
}

Thread t = new Thread() {
public void run() {
try {
Uri ISSUE_AUTH_TOKEN_URL = Uri.parse("https://www.google.com/accounts/IssueAuthToken?service=gaia&Session=false");
Uri TOKEN_AUTH_URL = Uri.parse("https://www.google.com/accounts/TokenAuth");

final HttpClient httpclient = new DefaultHttpClient();
httpclient.getParams().setBooleanParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, false);
httpclient.getParams().setBooleanParameter(ClientPNames.HANDLE_REDIRECTS, true);

String url = ISSUE_AUTH_TOKEN_URL.buildUpon().appendQueryParameter("SID", sid).appendQueryParameter("LSID", lsid).build().toString();
HttpPost getUberToken = new HttpPost(url);
HttpResponse response = httpclient.execute(getUberToken);

String uberToken = EntityUtils.toString(response.getEntity(), "UTF-8");

final String accessToken2 = TOKEN_AUTH_URL.buildUpon()
.appendQueryParameter("source", "android-browser")
.appendQueryParameter("auth", uberToken)
.appendQueryParameter("continue", "https://www.google.com/bookmarks/").build().toString();

//do stuff
} catch (Exception e) {
e.printStackTrace();
}
}
};
t.start();
}
}, null);
}
}, null);
} else {
//do stuff
}
} catch (OperationCanceledException e) {
finish();
} catch (Exception e) {
finish();
}
}
}, null);

关于安卓:谷歌认证+Ubertoken,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18153538/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com