Platform
LinkedIn으로 가입하기
9 분
linkedin으로 로그인하기 튜토리얼 소개 linkedin으로 로그인을 사용하면 사용자가 linkedin 계정을 사용하여 앱에 로그인할 수 있습니다 전제 조건 이 튜토리얼을 완료하려면 다음이 필요합니다 back4app에서 생성된 앱 다음 링크를 참조하세요 https //www back4app com/docs/get started/new parse app back4app에서 앱을 만드는 방법을 배우세요 back4app 앱을 위한 서브도메인 설정하기 다음 링크를 참조하세요 https //www back4app com/docs/platform/activating web hosting back4app에서 서브도메인을 만드는 방법을 배우세요 https //www linkedin com/developers 이 필요합니다 1 새로운 back4app 앱 만들기 우선, back4app에 기존 앱이 생성되어 있는지 확인해야 합니다 그러나 새로운 사용자라면 https //www back4app com/docs/get started/new parse app 을 확인하여 앱을 만드는 방법을 배울 수 있습니다 2 새로운 linkedin 앱 만들기 당신의 https //www linkedin com/developers 에 로그인하고 앱 만들기 앱 만들기 를 클릭한 후 oauth 클라이언트 id oauth 클라이언트 id 앱 이름을 선택하고 비즈니스 이메일 비즈니스 이메일 및 앱 로고 앱 로고 약관에 동의하고 앱 만들기 앱 만들기 새로 생성한 앱에서 확인 확인 을 클릭하여 앱의 소유권을 확인하세요 확인하려면 linkedin 페이지의 소유자 또는 관리자여야 합니다 확인 페이지에서 url 생성 url 생성 생성된 확인 url 확인 url 을 linkedin의 회사 페이지 관리자 또는 소유자 계정을 사용하여 방문하세요 확인 승인 확인 승인 앱이 확인되었는지 확인하세요 앱에서 인증 인증 탭으로 가서 리다이렉트 url 리다이렉트 url 필드를 채우고 업데이트 업데이트 3 코드를 가져오기 다음 url을 방문하여 client id client id , redirect url redirect url , 및 a random string a random string 을(를) 생성한 값으로 변경하세요 무작위 문자열은 csrf 공격을 방지하기 위한 것입니다 https //www linkedin com/oauth/v2/authorization?response type=code\&client id=client id\&redirect uri=redirect url\&state=a random string\&scope=r emailaddress 귀하의 linkedin 계정으로 로그인하면 리디렉션된 웹사이트의 url에 코드가 포함됩니다 url의 코드 부분만 복사하고 다음 curl 명령을 실행하여 값을 바꾸십시오 your code your code , your client id your client id , your client secret your client secret , 그리고 your redirect uri your redirect uri 귀하의 애플리케이션 값으로 대체하십시오 1 curl x post \\ 2 https //www linkedin com/oauth/v2/accesstoken \\ 3 h 'cache control no cache' \\ 4 h 'content type application/x www form urlencoded' \\ 5 d 'client id=your client id\&client secret=your client secret\&redirect uri=your redirect uri\&code=your code\&grant type=authorization code' 실행하면 액세스 토큰을 가져와야 합니다 기억하세요 코드는 한 번만 사용할 수 있습니다 오류가 발생하거나 토큰을 사용하지 않으면 코드를 다시 생성해야 다시 실행할 수 있습니다 4 개발 시작하기 linkedin으로 로그인 설정이 완료되었으므로 개발 프로세스를 시작할 수 있습니다 authdata의 형식은 다음과 같습니다 1 { 2 "linkedin" { 3 "id" "user's linkedin id (string)", 4 "access token" "an authorized linkedin access token for the user", 5 "is mobile sdk" true|false // set to true if you acquired the token through linkedin mobile sdk 6 } 7 } 여기 ios sdk를 위한 메서드가 있습니다 1 pfuser loginwithauthtype(inbackground "linkedin", authdata \["access token"\ tokenstring, "id" user, "is mobile sdk" true]) continuewith { task > any? in 2 3 } 그리고 android sdk를 위한 메서드는 다음과 같습니다 1 map\<string, string, bool> authdata = new hashmap\<string, string, bool>(); 2 authdata put("access token", tokenstring); 3 authdata put("id", user); 4 authdata put("is mobile sdk", true); 5 task\<parseuser> t = parseuser loginwithinbackground("google", authdata); 6 t continuewith(new continuation\<parseuser, void>() { 7 public void then(task task) throws exception { 8 if (task iscancelled()) { 9 log w(tag, "task cancelled"); 10 } else if (task isfaulted()) { 11 log w(tag, "save fail" + task geterror()); 12 utilities showtoast(getresources() getstring(r string errorlogin) + task geterror(), mainactivity this); 13 } else { 14 // the object was saved successfully 15 parseuser user = (parseuser)task getresult(); 16 log w(tag, "success " + user getobjectid() + " " + user getusername() + " " + user getemail() + " " + user getsessiontoken()); 17 } 18 } 19 }