Android Dropbox API를 사용하고 있습니다. 내 응용 프로그램의 주요 활동에서, 나는 dropbox API에 대한 인증 호출을하고 있습니다. 문제는 앱이 시작될 때마다 사용자가 앱이 드롭 보관함에 액세스 할 수있는 권한을 부여하도록 '허용'해야한다는 것입니다. 내 코드는 다음과 같습니다 :유효한 보관 용 계정 사용자 세션을 확인하는 방법은 무엇입니까?
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().requestFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main);
//clearKeys();
//Log.e(TAG, "keys cleared");
AppKeyPair appKeys = new AppKeyPair(APP_KEY, APP_SECRET);
AndroidAuthSession session = new AndroidAuthSession(appKeys, ACCESS_TYPE);
mDBApi = new DropboxAPI<AndroidAuthSession>(session);
mDBApi.getSession().startAuthentication(Main.this);
Log.e(TAG, "started authentication");
protected void onResume() {
super.onResume();
if (mDBApi.getSession().authenticationSuccessful()) {
try {
// MANDATORY call to complete auth.
// Sets the access token on the session
mDBApi.getSession().finishAuthentication();
if(mDBApi.getSession().authenticationSuccessful()){
Log.e(TAG, "Authentication finished");
}
AccessTokenPair tokens = mDBApi.getSession().getAccessTokenPair();
// Provide your own storeKeys to persist the access token pair
// A typical way to store tokens is using SharedPreferences
storeKeys(tokens.key, tokens.secret);
} catch (IllegalStateException e) {
Log.i("DbAuthLog", "Error authenticating", e);
}
}
}//end of onResume()
내가 앱이 그런 경우가 있다면 그래서 인증을 우회 할 수 auth'd 것을 알 수있는 방법을 찾을 필요가있다. 나는이 시점에서 어떻게 그것에 대해 가야할지 모르겠다. 아무도 도와 줄 수 있습니까?
저장된 액세스 토큰이 유효한지 확인하는 방법은 무엇입니까? –
@ShajeelAfzal "OAuth를 통해 노출 된 메소드 중 하나에 대해 승인 된 요청을하십시오."- https://api.dropbox.com/1/account/info에 요청하여 대답을 얻을 수 있는지 확인하십시오. –
안녕하세요! 답변 해주셔서 감사합니다. 내가 안드로이드에 대한 Dropbox 코어 라이브러리를 사용하고, 여전히 내가 api.dropbox.com/1/account/info를 사용해야합니까 아니면 당신이 동일한 일을 할 수있는 핵심 라이브러리에서 어떤 방법을 아십니까? –