Java 我可以以编程方式创建 Google 帐户吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2699008/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can I create a Google account programmatically?
提问by rowly
Does anybody know if via the google api in java I can create google accounts programmatically.
有谁知道我是否可以通过java中的google api以编程方式创建google帐户。
采纳答案by Basic
Yes
是的
(ish)
(是)
The Admin SDKDirectory API allows you to create accounts which work with Google tools (Gmail, Calendar, etc.) but are not @gmail.com / @googlemail.com accounts.
Admin SDKDirectory API 允许您创建使用 Google 工具(Gmail、日历等)但不是 @gmail.com / @googlemail.com 帐户的帐户。
This is used by companies to automate creation of accounts for online google tools when new users are added to networks and similar scenarios.
当新用户被添加到网络和类似场景时,公司会使用它来自动为在线谷歌工具创建帐户。
User management is documented here.
此处记录了用户管理。
This replaces the provisioning API which was deprecated in 2013.
这取代了 2013 年弃用的配置 API。
回答by DVK
You can do that theoretically, but Google's account creation - like other services - uses image recognition for confirmation that you're a user (aka CAPTCHA) and you need to be able to write image recognition program that can do that.
理论上您可以这样做,但 Google 的帐户创建 - 与其他服务一样 - 使用图像识别来确认您是用户(又名 CAPTCHA),并且您需要能够编写可以执行此操作的图像识别程序。
AFAIK there's no programmatic API from Google to create accounts, since doing so would open them up to spammers/scammers/etc... which the CAPTCA was meant to prevent.
AFAIK 没有来自 Google 的程序化 API 来创建帐户,因为这样做会使它们向垃圾邮件发送者/诈骗者/等开放……这是 CAPTCA 旨在防止的。
Why would you do that? I am not sure Google allows that in the first place as far as EULA.
为什么要这么做?就 EULA 而言,我不确定谷歌首先是否允许这样做。
回答by Dolph
The fact that Google's account creation UI requires a CAPTCHA is your first hint that the answer is NO.
Google 的帐户创建 UI 需要验证码这一事实是您第一个暗示答案是否定的。
回答by kurige
NO
不
The only possible way to do this would be to use a web automation framework. Python is great for web automation using tools such as mechanize. I've never done it in Java, but you should do a google search for java programmatic web browser
or java web automation
.
唯一可能的方法是使用 Web 自动化框架。Python 非常适合使用mechanize等工具进行网络自动化。我从来没有用 Java 做过,但你应该在谷歌上搜索java programmatic web browser
或java web automation
。
On top of that you would have to incorporate an OCR package to beat the captcha.
最重要的是,您必须合并一个 OCR 包来击败验证码。
There is a reason that google, nor anyone else, allows the programmatic creation of accounts. Spammers would have a field day. Within days there would be no valid accounts left for any new users to use. In short, it would be a disaster.
谷歌和其他任何人都允许以编程方式创建帐户是有原因的。垃圾邮件发送者将度过一天。几天之内,将没有任何有效帐户可供任何新用户使用。简而言之,这将是一场灾难。
回答by Andy S
As others have pointed out, you cannot create Google consumer accounts (ie, @gmail accounts) via any sort of API. It would create a field day for Spammers. To make it difficult for Spammers, Google uses tactics such as CAPTCHAs to prevent abuse.
正如其他人指出的那样,您不能通过任何类型的 API 创建 Google 消费者帐户(即 @gmail 帐户)。它将为垃圾邮件发送者创造一个现场日。为了让垃圾邮件发送者难以为继,Google 使用 CAPTCHA 等策略来防止滥用。
But, you cancreate Google Apps accounts via their Provisioning APIs. A Google Apps account is basically a white labeled version of Google Apps (Gmail, Calendar, Docs, etc) that is under your own domain name.
但是,您可以通过其Provisioning API创建 Google Apps 帐户。Google Apps 帐户基本上是您自己的域名下的 Google Apps(Gmail、日历、文档等)的白标版本。
For the same Spam concerns, your Google Apps account would have to be either a Premier domain (where you pay for every account you provision) or an Educational institution (I assume some sort of verification process for that). So, since you have to pay for each account, it's not a huge risk for spammers (unless they want to pay big $$$ for each account.. very unlikely).
对于同样的垃圾邮件问题,您的 Google Apps 帐户必须是 Premier 域(您为您提供的每个帐户支付费用)或教育机构(我假设有某种验证过程)。因此,由于您必须为每个帐户付费,因此对于垃圾邮件发送者而言,这并不是一个巨大的风险(除非他们想为每个帐户支付大笔费用……不太可能)。
回答by Adam
I am going to assume that you aren't telling us your use case which is really to have a convenient way to use google logins on your site (because that's the closest you'll get and be legit). I would check out using OpenIDin the same way SO does.
我将假设您没有告诉我们您的用例,这实际上是一种在您的网站上使用谷歌登录的便捷方式(因为这是您将获得的最接近且合法的方式)。我会以与 SO 相同的方式使用OpenID进行检查。
回答by S.H.
It depends on your definition of create account...
这取决于您对创建帐户的定义...
it is possible to create an account inside a google group, or domain. By using the code below you can create accounts for your google group/domain. For this scenario YES you CAN create a google account.
可以在 google 群组或域中创建帐户。通过使用下面的代码,您可以为您的 google 群组/域创建帐户。对于这种情况,是的,您可以创建一个 google 帐户。
However, if you want to create a google account as in @gmail.com... I really have not found a way to do it programatically.
但是,如果你想在@gmail.com 中创建一个谷歌帐户......我真的没有找到一种以编程方式完成的方法。
Here is the link of where to download the google api, and the Documentation. https://developers.google.com/google-apps/provisioning/#creating_a_user_account
这是下载 google api 和文档的链接。 https://developers.google.com/google-apps/provisioning/#creating_a_user_account
Good Luck.
祝你好运。
import sample.appsforyourdomain.AppsForYourDomainClient;
AppsForYourDomainClient client = new AppsForYourDomainClient(email, password, domain);
client.createUser(String username, String givenName, String familyName, String password)
回答by knocte
I am going to write an answer that has not been written so far, but which could actually break the EULA (if that's the case, can someone point out the specific paragraph of it that prevents this?).
我要写一个到目前为止还没有写的答案,但它实际上可能会破坏 EULA(如果是这种情况,有人可以指出它的具体段落来防止这种情况吗?)。
The solution is: redirect Google's CAPTCHA to your user.
解决方案是:将 Google 的 CAPTCHA 重定向到您的用户。
Assuming your software has a user, you could present them Google's captcha so the account is created by them, for your system, without them knowing.
假设您的软件有一个用户,您可以向他们展示 Google 的验证码,以便他们在他们不知情的情况下为您的系统创建帐户。
Would this work for you?
这对你有用吗?
回答by Zibri
The real answer is YES.
真正的答案是肯定的。
The fact is that we don't know (yet) how.
事实是我们不知道(还)如何。
The proof is that an account can be created from any android device without any captcha, without a phone number and without an email.
证明是可以从任何 Android 设备创建帐户,无需任何验证码、电话号码和电子邮件。
So the secretis inside android codebase.
所以秘密就在 android 代码库中。