2014-10-04 2 views
5

사용자가 Facebook, Twitter 및 Google+를 사용하여 로그인 할 수있는 구문 분석을 사용하고 있습니다. 현재로서는 Facebook과 Twitter만이 완벽하게 기능합니다.구문 분석 Google 플러스 로그인

나는 다음과 같은 방법으로 페이스 북과 트위터를 사용하여 로그인 처리했다 : 내가 구문 분석을 통해 Google+에서이를 달성하기 위해 알아 내려고 노력하고 있어요

private void onLoginButtonClicked() { 
     LoginActivity.this.progressDialog = ProgressDialog.show(
       LoginActivity.this, "", "Logging in...", true); 
     List<String> permissions = Arrays.asList("public_profile", "user_about_me", 
       "user_relationships", "user_birthday", "user_location"); 
     ParseFacebookUtils.logIn(permissions, this, new LogInCallback() { 
      @Override 
      public void done(ParseUser user, ParseException err) { 
       LoginActivity.this.progressDialog.dismiss(); 
       if (user == null) { 
        Log.d(IntegratingFacebookTutorialApplication.TAG, 
          "Uh oh. The user cancelled the Facebook login."); 
       } else if (user.isNew()) { 
        Log.d(IntegratingFacebookTutorialApplication.TAG, 
          "User signed up and logged in through Facebook!"); 
        showUserDetailsActivity(); 

       } else { 
        Log.d(IntegratingFacebookTutorialApplication.TAG, 
          "User logged in through Facebook!"); 
       moodpage();    

       } 
      } 
     }); 
    } 

    private void onTwitterButtonClicked() { 
     ParseTwitterUtils.logIn(this, new LogInCallback() { 
       @Override 
       public void done(ParseUser user, ParseException err) { 
       if (user == null) { 
        Log.d("MyApp", "Uh oh. The user cancelled the Twitter login."); 
       } else if (user.isNew()) { 
        Log.d("MyApp", "User signed up and logged in through Twitter!"); 
        showUserDetailsActivity();   
        } else { 
        Log.d("MyApp", "User logged in through Twitter!"); 
        moodpage();    } 
       } 

      }); 
    } 

. 누군가 내가 Parse Rest API를 살펴 보도록 제안했지만, 익숙하지 않아 더 많은 안내가 필요합니다.

임의의 설명을 이해할 수있을 것이다.

+0

[여기] (https://parse.com/docs/rest)는 Parse API 설명서이며 [여기] (https://parse.com/docs/android_guide)는 Android 가이드입니다. 적어도 Google에 시도 했습니까? –

+0

@ user3907211 Google + 로그인을 용이하게하는 다른 자바 라이브러리가 있습니다. 관심있어? – Alboz

+0

나는 흥미가있을 것이다. 이를 수행하는 데는 여러 가지 방법이 있지만 구문 분석에 관계를 작성하여 구문 분석에서 사용자 로그인 google + 정보를 저장하려고합니다. – John

답변

0

이 당 :

http://blog.parse.com/announcements/adding-third-party-authentication-to-your-web-app/

이 :

https://parse.com/tutorials/adding-third-party-authentication-to-your-web-app

그들에 대한 이해

당신은 어떤 알고리즘을 사용하여 암호를 생성해야

앱 또는 클라우드/백엔드에서 af

// given Google Plus login (Using their Api) i.e. no Parse yet at this point 
int id = 12345; // assume that this is google+ id (After successfully logging in) 

ParseUser user = new ParseUser(); 
user.setUsername("google-plus-" + String.valueOf(id)); 
user.setPassword(hashMyPassword(id)); // Create password based on the id 
user.setEmail("[email protected]"); 

user.signUpInBackground(new SignUpCallback() { 
    public void done(ParseException e) { 
    if (e == null) { 
     // Hooray! Let them use the app now. 
    } else { 
     // Sign up didn't succeed. Look at the ParseException 
     // to figure out what went wrong 
    } 
    } 
}); 

이 솔루션에 대한 한 가지 중요한 것은 :

TER 성공적으로 Google+에/Github에서/무엇이든

simeple 구현 (하지만 확보 아니에요 앱에 그것을 가지고)로 로그인 앱의 ID를 기반으로하는 ID/비밀번호를 사용하는 것이 안전하지 않은 경우 Google+ 토큰/UserId를 백엔드/클라우드에 전송 한 다음 백엔드/클라우드가이 토큰/ID가 유효한지 확인한 다음 그것에서 사용자 이름/암호 및 분석 사용자와 교환하십시오.

아이디어를 얻길 바랍니다.

+0

어떻게 Google+ 토큰을 보낼 수 있습니까 ?? 세션 토큰과 연결된 새 사용자 계정을 만들 수 있습니까? –