В настоящее время я использую Android API One Drive, доступный здесь:
https://github.com/OneDrive/onedrive-explorer-android
Я могу успешно выполнить OAuth, чтобы дать разрешения моему приложению.
Однако я не могу использовать API в будущем. Я продолжаю получать ошибки 401 об отказе в разрешении.
public static final List<String> SCOPES = Arrays.asList("wl.signin", "onedrive.readwrite");
mAuthClient = new AuthClient(this, OneDriveOAuthConfig.getInstance(), OneDriveController.ONEDRIVE_CLIENT_ID);
mAuthClient.login(this, OneDriveController.SCOPES, mAuthListener);
Вышеупомянутое работает, но я не могу использовать следующее позже
public void setAuthClient()
{
if (mAuthClient == null)
{
mAuthClient = new AuthClient(getContext(), OneDriveOAuthConfig.getInstance(), ONEDRIVE_CLIENT_ID);
mAuthClient.initialize(SCOPES, mAuthListener, null, mAccount.getToken());
}
}
AuthListener mAuthListener = new AuthListener() {
@Override
public void onAuthComplete(AuthStatus status, AuthSession session, Object userState) {
}
@Override
public void onAuthError(AuthException exception, Object userState) {
exception.printStackTrace();
}
};
/**
* Get an instance of the OneDrive service
*
* @return The OneDrive Service
*/
synchronized IOneDriveService getOneDriveService() {
if (mODConnection == null) {
setAuthClient();
final ODConnection connection = new ODConnection(mAuthClient);
connection.setVerboseLogcatOutput(true);
mODConnection = connection.getService();
}
return mODConnection;
}
@Override
public double getRemainingSpace() {
getOneDriveService().getDrive(new Callback<Drive>() {
@Override
public void success(Drive drive, Response response) {
remaining_space = drive.Quota.Remaining.doubleValue();
}
@Override
public void failure(RetrofitError error) {
error.printStackTrace();
}
});
return remaining_space;
}
Как именно я могу заставить API делать то, что я хочу?
Спасибо,
Парт