19

有沒有辦法在Google雲端點上使用另一個OAuth2提供商?我的意思是,例如,從Facebook獲取身份驗證,並使用它與我們使用Google帳戶身份驗證的相同方式(使用gapi js並將用戶類別放在@ApiMethod上)谷歌雲端點與另一個oAuth2提供商

+0

看看這個:http://stackoverflow.com/questions/18716674/facebook-login-in-google-cloud-endpoints/22495862#22495862 – 2014-04-03 16:04:14

回答

5

不,我遇到了其他人詢問此問題以及谷歌人(如果我沒記錯的話)是端點用戶身份驗證目前僅支持Google帳戶。

+0

有沒有一種方法來實現替代?就像在會話中存儲用戶一樣? (我剛剛發現該會話在Google Cloud Endpoint中也不起作用) – 2013-04-08 15:41:06

+1

當然,您可以實現您想要的任何替代方法,並且可以通過端點傳遞系統的令牌,但是您必須自己實施身份驗證。 – Tom 2013-04-08 15:51:41

+1

這裏的問題是如何控制用戶會話,因爲Google Endpoint沒有提供會話,對嗎? – 2013-04-08 16:32:25

7

你必須實現自己的Authenticator和更新@Api配置。在此基礎上answer一個簡單的認證會是這樣的:

public class MyAuthenticator implements Authenticator { 

    @Override 
    public User authenticate(HttpServletRequest request) { 
     String token = request.getHeader("Authorization"); 
     if (token != null) { 
      // apply your Facebook/Twitter/OAuth2 authentication 
      String user = authenticate(token); 
      if (user != null) { 
       return new User(user); 
      } 
     } 
     return null; 
    } 
} 

而且你的API定義

@Api(name = "example", authenticators = {MyAuthenticator.class}) 

更多您可以在Google documentation找到自定義驗證器。

+0

是否有python等價物? – 2015-04-30 09:23:31

+0

@JanuszSkonieczny我不知道它是否可用於python,你應該問一個關於SO – tomrozb 2015-05-02 11:04:54

+0

的新問題任何人都知道如何把數據放在android客戶端的頭文件中? – myfknoll 2015-06-11 20:09:50

相關問題