forked from clementine-player/Clementine
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More or less working Skydrive authentication.
- Loading branch information
Showing
12 changed files
with
141 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#include "skydriveservice.h" | ||
|
||
#include "oauthenticator.h" | ||
|
||
namespace { | ||
|
||
static const char* kServiceName = "Skydrive"; | ||
static const char* kServiceId = "skydrive"; | ||
static const char* kSettingsGroup = "Skydrive"; | ||
|
||
static const char* kClientId = "00000000400E7C78"; | ||
static const char* kClientSecret = "B0KLZjEgC5SpW0KknrsBFwlaKmGThaAk"; | ||
|
||
static const char* kOAuthEndpoint = | ||
"https://login.live.com/oauth20_authorize.srf"; | ||
static const char* kOAuthTokenEndpoint = | ||
"https://login.live.com/oauth20_token.srf"; | ||
static const char* kOAuthScope = "wl.basic wl.skydrive wl.offline_access"; | ||
|
||
} // namespace | ||
|
||
SkydriveService::SkydriveService( | ||
Application* app, | ||
InternetModel* parent) | ||
: CloudFileService( | ||
app, parent, kServiceName, kServiceId, | ||
QIcon(":providers/skydrive.png"), SettingsDialog::Page_Skydrive) { | ||
} | ||
|
||
bool SkydriveService::has_credentials() const { | ||
return true; | ||
} | ||
|
||
void SkydriveService::Connect() { | ||
OAuthenticator* oauth = new OAuthenticator( | ||
kClientId, kClientSecret, OAuthenticator::RedirectStyle::REMOTE, this); | ||
QSettings s; | ||
s.beginGroup(kSettingsGroup); | ||
if (s.contains("refresh_token")) { | ||
oauth->RefreshAuthorisation( | ||
kOAuthTokenEndpoint, s.value("refresh_token").toString()); | ||
} else { | ||
oauth->StartAuthorisation( | ||
kOAuthEndpoint, | ||
kOAuthTokenEndpoint, | ||
kOAuthScope); | ||
} | ||
|
||
NewClosure(oauth, SIGNAL(Finished()), | ||
this, SLOT(ConnectFinished(OAuthenticator*)), oauth); | ||
} | ||
|
||
void SkydriveService::ConnectFinished(OAuthenticator* oauth) { | ||
qLog(Debug) << oauth->access_token() | ||
<< oauth->refresh_token(); | ||
|
||
QSettings s; | ||
s.beginGroup(kSettingsGroup); | ||
|
||
s.setValue("refresh_token", oauth->refresh_token()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#ifndef SKYDRIVESERVICE_H | ||
#define SKYDRIVESERVICE_H | ||
|
||
#include "cloudfileservice.h" | ||
|
||
class OAuthenticator; | ||
|
||
class SkydriveService : public CloudFileService { | ||
Q_OBJECT | ||
|
||
public: | ||
SkydriveService( | ||
Application* app, | ||
InternetModel* parent); | ||
|
||
protected: | ||
// CloudFileService | ||
virtual bool has_credentials() const; | ||
virtual void Connect(); | ||
|
||
private slots: | ||
void ConnectFinished(OAuthenticator* oauth); | ||
|
||
}; | ||
|
||
#endif // SKYDRIVESERVICE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters