簡體   English   中英

哪些正確的Google+作用域變量可以獲取電子郵件地址並發布?

[英]Which are the correct Google+ scope variables to get email address and to post?

我正在使用spring-social-google(從git repo構建)來允許人們登錄到我的Spring MVC應用程序(我已經在使用facebook,twitter和linedin)。 以下表格允許我進行身份驗證,但不會返回電子郵件地址,並且禁止發布到Google+時間軸:

<form action="<c:url value="/register/social/${providerId}" />" method="POST" id ="${providerId}Form" name = "${providerId}Form">
    <button type="submit"><img src="<c:url value='/resources/${providerId}/sign-in-with-${providerId}.png'/>" border="0"/></button>
    <input type="hidden" name="scope" value="https://www.googleapis.com/auth/plus.profile.emails.read" />                   
</form>

我認為問題是我沒有正確的范圍變量。 我在這里https://developers.google.com/+/api/oauth嘗試了一些組合,但是我被告知范圍變量都是錯誤的。 我需要哪些?

這是我用來獲取電子郵件地址的代碼:

public final class LoginConnectionSignUp implements ConnectionSignUp 
{   
    public String execute(Connection<?> connection) 
    {
        final UserProfile up = connection.fetchUserProfile();
        final String email = up.getEmail();
        // ...
    }

}

這里有幾個問題:

目前Google的API不支持發布到Google+流。 該軟件包似乎可以讓您創建“應用活動記錄”,這些記錄存儲在用戶的個人資料中...但這些不是發布到信息流中。 為了生成應用活動,您需要包括https://www.googleapis.com/auth/plus.login范圍。

此外,您可以包括email范圍或https://www.googleapis.com/auth/plus.profile.emails.read范圍。 通過這些作用域,您應該能夠將電子郵件地址作為對的調用的一部分

Person person = google.plusOperations().getPerson("me");

所以您的輸入標簽應該看起來像

<input type="hidden" name="scope" value="https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/plus.profile.emails.read" />                   

(請注意要使用的兩個示波器之間的空間)。

重要說明 :文檔討論如何通過諸如

GoogleUserInfo userInfo = google.userOperations().getUserInfo();

雖然目前暫時可以使用,但已棄用並計划在9月將其刪除。 userinfo范圍也被設置為此時不被使用。 不要使用此方法或這些范圍。 (並聯系作者以使其不贊成使用。)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM