Authorization_failed 에러가 납니다

public class MainActivity extends AppCompatActivity {
private static String TAG = "[Sosim]";
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    redirectLoginActivity();

    System.out.println("your hash: " + getKeyHash(this));
}

private void onClickLogout() {
    UserManagement.getInstance().requestLogout(new LogoutResponseCallback() {
        @Override
        public void onCompleteLogout() {
            redirectLoginActivity();
        }
    });
}

public void redirectLoginActivity() {
    Toast.makeText(getApplicationContext(), "redirect login0", Toast.LENGTH_SHORT).show();
    Intent intent = new Intent(this, LoginActivity.class);
    startActivity(intent);
    finish();
}

public static String getKeyHash(Context context) {
    PackageInfo packageInfo = null;
    try {
        packageInfo = context.getApplicationContext().getPackageManager().getPackageInfo("com.goldenmine.sosim2", PackageManager.GET_SIGNATURES);
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    }
    if (packageInfo == null)
        return null;

    for (Signature signature : packageInfo.signatures) {
        try {
            MessageDigest md = MessageDigest.getInstance("SHA");
            md.update(signature.toByteArray());
            return Base64.encodeToString(md.digest(), Base64.NO_WRAP);
        } catch (NoSuchAlgorithmException e) {
            Log.w(TAG, "Unable to get MessageDigest. signature=" + signature, e);
        }
    }
    return null;
}

}

public class LoginActivity extends AppCompatActivity {
private SessionCallback callback;

@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);

    callback = new SessionCallback();
    Session.getCurrentSession().addCallback(callback);
    Session.getCurrentSession().checkAndImplicitOpen();
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (Session.getCurrentSession().handleActivityResult(requestCode, resultCode, data)) {
        return;
    }

    super.onActivityResult(requestCode, resultCode, data);
}

@Override
protected void onDestroy() {
    super.onDestroy();
    Session.getCurrentSession().removeCallback(callback);
}

private class SessionCallback implements ISessionCallback {

    @Override
    public void onSessionOpened() {
        redirectSignupActivity();
    }

    @Override
    public void onSessionOpenFailed(KakaoException exception) {
        System.out.println("errtype: " + exception.getErrorType());
        if (exception != null) {
            //Logger.e(exception);
            exception.printStackTrace();
        }
        Toast.makeText(getApplicationContext(), "fail", Toast.LENGTH_SHORT).show();
    }
}

protected void redirectSignupActivity() {
    Toast.makeText(getApplicationContext(), "redirect signup1", Toast.LENGTH_SHORT).show();

    final Intent intent = new Intent(this, SignupActivity.class);
    startActivity(intent);
    finish();


}

}

public class SignupActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_signup);

    requestMe();
}

private void requestMe() {
    List<String> keys = new ArrayList<>();
    keys.add("properties.nickname");
    keys.add("properties.profile_image");
    keys.add("kakao_account.email");

    UserManagement.getInstance().me(keys, new MeV2ResponseCallback() {
        @Override
        public void onFailure(ErrorResult errorResult) {
            String message = "failed to get user info. msg=" + errorResult;
            //Logger.d(message);
            System.out.println(message);
        }

        @Override
        public void onSessionClosed(ErrorResult errorResult) {
            redirectLoginActivity();
        }

        @Override
        public void onSuccess(MeV2Response response) {
            //Logger.d("user id : " + response.getId());
            //Logger.d("email: " + response.getKakaoAccount().getEmail());
            //Logger.d("profile image: " + response.getKakaoAccount()
            //        .getProfileImagePath());

            Toast.makeText(getApplicationContext(), "id: " + response.getId() + ", email:" + response.getKakaoAccount().getEmail(), Toast.LENGTH_SHORT).show();
            redirectMainActivity();
        }
    });
}

public void redirectMainActivity() {
    Toast.makeText(getApplicationContext(), "redirect main2", Toast.LENGTH_SHORT).show();
    Intent intent = new Intent(this, MainActivity.class);
    startActivity(intent);
    finish();
}

public void redirectLoginActivity() {
    Toast.makeText(getApplicationContext(), "redirect login2", Toast.LENGTH_SHORT).show();
    Intent intent = new Intent(this, LoginActivity.class);
    startActivity(intent);
    finish();
}

}

카카오 연동 처음해보는 초보입니다
위와 같이 코드를 짰는데 카카오톡 로그인을 하려고 하면 onSessionOpenFailed가 됩니다
1주일째 보고있는데 문제를 도통 모르겠네요 살려주세요 ㅠ

onSessionOpenFailed에서 에러 로그를 한번 확인해 보셨나요?

10-24 02:37:02.435 21309-21309/com.goldenmine.sosim2 E/kakao.sdk: AUTHORIZATION_FAILED: code = -1, msg = net::ERR_CACHE_MISS, url = https://auth.kakao.com/kakao_accounts/view/login?continue=https%3A%2F%2Fkauth.kakao.com%2Foauth%2Fauthorize%3Fclient_id%3Da3cfba4cf519557caa64a34ce5135d9d%26approval_type%3Dindividual%26redirect_uri%3Dkakaoa3cfba4cf519557caa64a34ce5135d9d%3A%2F%2Foauth%26response_type%3Dcode
at com.kakao.auth.authorization.authcode.KakaoAuthCodeManager.onAuthCodeReceived(KakaoAuthCodeManager.java:228)
at com.kakao.auth.authorization.authcode.WebAuthCodeService.onWebViewCompleted(WebAuthCodeService.java:78)
at com.kakao.auth.authorization.authcode.WebAuthCodeService.onReceivedResult(WebAuthCodeService.java:100)
at com.kakao.auth.authorization.authcode.WebAuthCodeService$1.onReceiveResult(WebAuthCodeService.java:107)
at android.os.ResultReceiver$MyRunnable.run(ResultReceiver.java:50)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

오류는 이렇게나오더라구요 ㅠㅠ 다른분들은 어떻게 하라고 메세지라도 뜨던데 아무것도 안떠서…

우선 위 에러가 많이 발생하는 이유 중 하나가 AndroidManifest.xml에 INTERNET 권한을 명시하지 않아서인데요. 이 부분 한번 확인해 보시겠어요?

참고 링크: https://stackoverflow.com/questions/26515991/chrome-err-cache-miss

아… 감사합니다 해결됐습니다!!!
인터넷 퍼미션 추가하고 어찌어찌하다보니 연동됐네요 감사합니다 ㅠㅠ

1개의 좋아요