2011-12-30 4 views
5

webapp2의 auth 모듈을 사용하며 'facebook : fbuserid12121212'와 같은 auth_id를 추가하고이를 사용자의 auth_id : s 목록에 추가하는 방법을 알고 싶습니다. 하지만 API에서 API를 통해이를 수행 할 수있는 기능이 없습니다. 어떻게 할 수 있는지 말해 주시겠습니까?webapp2와 함께 auth_id를 추가하는 방법은 무엇입니까?

감사합니다.

+1

업데이트/답변을 실제 답변으로 옮기는 것이 좋습니다 (질문에 답이 표시되지 않도록). 이 문제를 해결해 주셔서 감사합니다. –

+1

@jgeewax 답변 섹션으로 이동했습니다. – allyourcode

답변

2

이것은 OP에서 찾은 답변입니다. 이 질문은 답하지 않도록 난 여기가 복사 해요 : 내가 찾던 기능이 user.auth_ids.append는

This was answered in the google group이고 나는 그것을 사용하기 위해 현재 사용하는 코드는 다음과 같습니다

@user_required 
def post(self, **kwargs): 
    email = self.request.POST.get('email') 
    auser = self.auth.get_user_by_session() 
    userid = auser['user_id'] 
    user = auth_models.User.get_by_id(auser['user_id']) 
    existing_user = auth_models.User.get_by_auth_id(email) 

    if existing_user is not None: 
     # You need to handle duplicates. 
     # Maybe you merge the users? Maybe you return an error? 
     pass 

    # Test the uniqueness of the auth_id. We must do this to 
    # be consistent with User.user_create() 
    unique = '{0}.auth_id:{1}'.format(auth_models.__class__.__name__, email) 

    if auth_models.User.unique_model.create(unique): 
     # Append email to the auth_ids list 
     user.auth_ids.append(email) 
     user.put() 
     return "Email updated" 
    else: 
     return 'some error' 
+0

사용자의 auth_id 검색 방법은 어떻습니까? – deltanine

관련 문제