【发布时间】:2018-07-15 19:57:30
【问题描述】:
我正在尝试获取用户电子邮件,这是我在应用程序中通过 Youtube 执行 Oauth2 时用来登录的。代码类似这样:
YouTube client = new YouTube.Builder(GoogleNetHttpTransport.newTrustedTransport(), JacksonFactory
.getDefaultInstance(), credential)
.setApplicationName("app_name").build();
YouTube.Channels.List channelListByIdRequest = client.channels().list("snippet,contentDetails,statistics");
channelListByIdRequest.setMine(true);
ChannelListResponse channelListResponse = channelListByIdRequest.execute();
这里我提取了频道 api,根据文档,它类似于 v3 中的用户 api。但是,无论是在 Channel 还是在任何其他 API 中,我都找不到如何获取我登录时使用的电子邮件。如何访问这些信息?
【问题讨论】:
-
不要认为 Youtube API 是用来获取电子邮件等个人信息的。但是,请尝试使用 GoogleIdToken.Payload,因为它有 getEmail() 方法。
标签: java youtube youtube-api youtube-data-api