Handle google drive token.
Use LoadResult auth header mechanism to pass auth token to pipeline as a header instead of obsolete query string method.
This commit is contained in:
parent
e338939c8b
commit
8e6d09d445
|
@ -132,9 +132,12 @@ void Client::FetchUserInfoFinished(ConnectResponse* response,
|
||||||
emit Authenticated();
|
emit Authenticated();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QByteArray Client::GetAuthHeader() const {
|
||||||
|
return QString("Bearer %1").arg(access_token_).toUtf8();
|
||||||
|
}
|
||||||
|
|
||||||
void Client::AddAuthorizationHeader(QNetworkRequest* request) const {
|
void Client::AddAuthorizationHeader(QNetworkRequest* request) const {
|
||||||
request->setRawHeader("Authorization",
|
request->setRawHeader("Authorization", GetAuthHeader());
|
||||||
QString("Bearer %1").arg(access_token_).toUtf8());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GetFileResponse* Client::GetFile(const QString& file_id) {
|
GetFileResponse* Client::GetFile(const QString& file_id) {
|
||||||
|
|
|
@ -149,6 +149,8 @@ class Client : public QObject {
|
||||||
GetFileResponse* GetFile(const QString& file_id);
|
GetFileResponse* GetFile(const QString& file_id);
|
||||||
ListChangesResponse* ListChanges(const QString& cursor);
|
ListChangesResponse* ListChanges(const QString& cursor);
|
||||||
|
|
||||||
|
QByteArray GetAuthHeader() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void Authenticated();
|
void Authenticated();
|
||||||
|
|
||||||
|
|
|
@ -209,11 +209,7 @@ QUrl GoogleDriveService::GetStreamingUrlFromSongId(const QString& id) {
|
||||||
return QUrl();
|
return QUrl();
|
||||||
}
|
}
|
||||||
|
|
||||||
QUrl url(response->file().download_url());
|
return QUrl(response->file().download_url());
|
||||||
QUrlQuery url_query(url);
|
|
||||||
url_query.addQueryItem("access_token", client_->access_token());
|
|
||||||
url.setQuery(url_query);
|
|
||||||
return url;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GoogleDriveService::ShowContextMenu(const QPoint& global_pos) {
|
void GoogleDriveService::ShowContextMenu(const QPoint& global_pos) {
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
#include "googledriveurlhandler.h"
|
#include "googledriveurlhandler.h"
|
||||||
|
|
||||||
|
#include "googledriveclient.h"
|
||||||
#include "googledriveservice.h"
|
#include "googledriveservice.h"
|
||||||
|
|
||||||
GoogleDriveUrlHandler::GoogleDriveUrlHandler(GoogleDriveService* service,
|
GoogleDriveUrlHandler::GoogleDriveUrlHandler(GoogleDriveService* service,
|
||||||
|
@ -29,5 +30,7 @@ UrlHandler::LoadResult GoogleDriveUrlHandler::StartLoading(const QUrl& url) {
|
||||||
QUrl real_url = service_->GetStreamingUrlFromSongId(file_id);
|
QUrl real_url = service_->GetStreamingUrlFromSongId(file_id);
|
||||||
LoadResult::Type type = real_url.isValid() ? LoadResult::TrackAvailable
|
LoadResult::Type type = real_url.isValid() ? LoadResult::TrackAvailable
|
||||||
: LoadResult::NoMoreTracks;
|
: LoadResult::NoMoreTracks;
|
||||||
return LoadResult(url, type, real_url);
|
LoadResult res(url, type, real_url);
|
||||||
|
res.auth_header_ = service_->client()->GetAuthHeader();
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue