Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
SiCKRAGE
sickrage
Commits
92752289
Commit
92752289
authored
Nov 17, 2017
by
echel0n
Browse files
Updated SiCKRAGE API to use client credentials
parent
af869a2b
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
changelog.md
View file @
92752289
# Changelog
-
*
b17df67 - 2017-11-16: Updated download link for NewPCT torrent provider
-
*
1a05445 - 2017-11-17: Updated SiCKRAGE API to use client credentials
-
*
af869a2 - 2017-11-16: Updated download link for NewPCT torrent provider
-
*
019c736 - 2017-11-15: Release v9.2.5
-
*
ab16911 - 2017-11-15: Release v9.2.4
-
*
fb16c64 - 2017-11-15: Updated SiCKRAGE API to use OAuth2
...
...
dist/js/core.js
View file @
92752289
...
...
@@ -2891,11 +2891,9 @@ jQuery(document).ready(function ($) {
$
(
'
#testAPI
'
).
click
(
function
()
{
$
(
'
#testAPI-result
'
).
html
(
SICKRAGE
.
loadingHTML
);
var
api_username
=
$
(
'
#api_username
'
).
val
();
var
api_password
=
$
(
'
#api_password
'
).
val
();
$
.
get
(
SICKRAGE
.
srWebRoot
+
'
/home/testAPI
'
,
{
'
username
'
:
api_username
,
'
password
'
:
api_password
'
client_id
'
:
$
(
'
#api_client_id
'
).
val
()
,
'
client_secret
'
:
$
(
'
#api_client_secret
'
).
val
()
},
function
(
data
)
{
$
(
'
#testAPI-result
'
).
html
(
data
);
...
...
sickrage/core/api/__init__.py
View file @
92752289
from
__future__
import
unicode_literals
import
json
from
urlparse
import
urljoin
from
oauthlib.oauth2
import
Legacy
ApplicationClient
from
oauthlib.oauth2
import
Backend
ApplicationClient
from
requests_oauthlib
import
OAuth2Session
import
sickrage
...
...
@@ -11,12 +10,11 @@ from sickrage.core.api.exceptions import unauthorized, error
class
API
(
object
):
def
__init__
(
self
,
username
=
None
,
password
=
None
):
self
.
client_id
=
'5YBSSD10UQN644DC13OHURJCESCOQBVR'
def
__init__
(
self
,
client_id
=
None
,
client_secret
=
None
):
self
.
api_url
=
'https://api.sickrage.ca/'
self
.
token_url
=
urljoin
(
self
.
api_url
,
'oauth/v2/token'
)
self
.
username
=
username
self
.
password
=
password
self
.
client_id
=
client_id
self
.
client_secret
=
client_secret
self
.
token
=
None
self
.
client
=
None
self
.
login
()
...
...
@@ -25,23 +23,21 @@ class API(object):
if
self
.
client
and
self
.
token
:
return
True
self
.
username
=
self
.
username
or
sickrage
.
app
.
config
.
api_username
self
.
password
=
self
.
password
or
sickrage
.
app
.
config
.
api_password
credentials
=
{
'client_id'
:
self
.
client_id
or
sickrage
.
app
.
config
.
api_client_id
,
'client_secret'
:
self
.
client_secret
or
sickrage
.
app
.
config
.
api_client_secret
}
if
self
.
username
and
self
.
password
:
oauth
=
OAuth2Session
(
client
=
LegacyApplicationClient
(
client_id
=
self
.
client_id
))
oauth
=
OAuth2Session
(
client
=
BackendApplicationClient
(
client_id
=
credentials
[
'client_id'
]))
try
:
self
.
token
=
oauth
.
fetch_token
(
token_url
=
self
.
token_url
,
client_id
=
self
.
client_id
,
timeout
=
30
,
username
=
self
.
username
,
password
=
self
.
password
)
self
.
client
=
OAuth2Session
(
self
.
client_id
,
token
=
self
.
token
,
auto_refresh_url
=
self
.
token_url
,
auto_refresh_kwargs
=
{
"client_id"
:
self
.
client_id
},
token_updater
=
self
.
token_saver
)
try
:
self
.
token
=
oauth
.
fetch_token
(
token_url
=
self
.
token_url
,
timeout
=
30
,
**
credentials
)
self
.
client
=
OAuth2Session
(
credentials
[
'client_id'
],
token
=
self
.
token
,
auto_refresh_url
=
self
.
token_url
,
auto_refresh_kwargs
=
credentials
,
token_updater
=
self
.
token_saver
)
return
True
except
Exception
:
pass
return
True
except
Exception
as
e
:
pass
def
logout
(
self
):
self
.
token
=
self
.
client
=
None
...
...
sickrage/core/config.py
View file @
92752289
...
...
@@ -74,8 +74,8 @@ class Config(object):
self
.
enable_api
=
False
self
.
enable_api_providers_cache
=
False
self
.
api_
username
=
""
self
.
api_
password
=
""
self
.
api_
client_id
=
""
self
.
api_
client_secret
=
""
self
.
version_notify
=
True
self
.
auto_update
=
True
...
...
@@ -698,8 +698,8 @@ class Config(object):
'General'
:
{
'enable_api'
:
True
,
'enable_api_providers_cache'
:
True
,
'api_
username
'
:
''
,
'api_
password
'
:
''
,
'api_
client_id
'
:
''
,
'api_
client_secret
'
:
''
,
'log_size'
:
1048576
,
'calendar_unprotected'
:
False
,
'https_key'
:
os
.
path
.
abspath
(
os
.
path
.
join
(
sickrage
.
PROG_DIR
,
'server.key'
)),
...
...
@@ -1391,8 +1391,8 @@ class Config(object):
self
.
config_version
=
self
.
check_setting_int
(
'General'
,
'config_version'
)
self
.
enable_api
=
self
.
check_setting_bool
(
'General'
,
'enable_api'
)
self
.
enable_api_providers_cache
=
self
.
check_setting_bool
(
'General'
,
'enable_api_providers_cache'
)
self
.
api_
username
=
self
.
check_setting_str
(
'General'
,
'api_
username
'
,
censor
=
True
)
self
.
api_
password
=
self
.
check_setting_str
(
'General'
,
'api_
password
'
,
censor
=
True
)
self
.
api_
client_id
=
self
.
check_setting_str
(
'General'
,
'api_
client_id
'
,
censor
=
True
)
self
.
api_
client_secret
=
self
.
check_setting_str
(
'General'
,
'api_
client_secret
'
,
censor
=
True
)
self
.
debug
=
sickrage
.
app
.
debug
or
self
.
check_setting_bool
(
'General'
,
'debug'
)
self
.
last_db_compact
=
self
.
check_setting_int
(
'General'
,
'last_db_compact'
)
self
.
log_nr
=
self
.
check_setting_int
(
'General'
,
'log_nr'
)
...
...
@@ -1865,8 +1865,8 @@ class Config(object):
'last_db_compact'
:
self
.
last_db_compact
,
'enable_api'
:
int
(
self
.
enable_api
),
'enable_api_providers_cache'
:
int
(
self
.
enable_api_providers_cache
),
'api_
username
'
:
self
.
api_
username
,
'api_
password'
:
self
.
api_password
,
'api_
client_id
'
:
self
.
api_
client_id
,
'api_
client_secret'
:
self
.
api_client_secret
,
'git_autoissues'
:
int
(
self
.
git_autoissues
),
'git_username'
:
self
.
git_username
,
'git_password'
:
self
.
git_password
,
...
...
sickrage/core/webserver/static/js/core.min.js
View file @
92752289
This diff is collapsed.
Click to expand it.
sickrage/core/webserver/views.py
View file @
92752289
...
...
@@ -738,8 +738,8 @@ class Home(WebHandler):
return
False
@
staticmethod
def
testAPI
(
username
=
None
,
password
=
None
):
result
=
API
(
username
,
password
).
token
def
testAPI
(
client_id
=
None
,
client_secret
=
None
):
result
=
API
(
client_id
,
client_secret
).
token
if
result
:
return
_
(
'API access successful'
)
else
:
...
...
@@ -3815,16 +3815,16 @@ class ConfigGeneral(Config):
fuzzy_dating
=
None
,
trim_zero
=
None
,
date_preset
=
None
,
date_preset_na
=
None
,
time_preset
=
None
,
indexer_timeout
=
None
,
download_url
=
None
,
rootDir
=
None
,
theme_name
=
None
,
default_page
=
None
,
git_reset
=
None
,
git_username
=
None
,
git_password
=
None
,
git_autoissues
=
None
,
gui_language
=
None
,
display_all_seasons
=
None
,
showupdate_stale
=
None
,
notify_on_login
=
None
,
api_
username
=
None
,
api_
password
=
None
,
use_api
=
None
,
enable_api_providers_cache
=
None
,
**
kwargs
):
display_all_seasons
=
None
,
showupdate_stale
=
None
,
notify_on_login
=
None
,
api_
client_id
=
None
,
api_
client_secret
=
None
,
use_api
=
None
,
enable_api_providers_cache
=
None
,
**
kwargs
):
results
=
[]
# API
sickrage
.
app
.
config
.
enable_api
=
checkbox_to_value
(
use_api
)
sickrage
.
app
.
config
.
enable_api_providers_cache
=
checkbox_to_value
(
enable_api_providers_cache
)
sickrage
.
app
.
config
.
api_
username
=
api_username
sickrage
.
app
.
config
.
api_
password
=
api_password
sickrage
.
app
.
config
.
api_
client_id
=
api_client_id
sickrage
.
app
.
config
.
api_
client_secret
=
api_client_secret
# Language
sickrage
.
app
.
config
.
change_gui_lang
(
gui_language
)
...
...
sickrage/core/webserver/views/config/general.mako
View file @
92752289
...
...
@@ -27,7 +27,7 @@
<div class="row tab-pane">
<div class="col-lg-3 col-md-4 col-sm-4 col-xs-12 tab-pane-desc">
<h3>${_('SiCKRAGE API')}</h3>
<p>${_('
Login info
and options for api.sickrage.ca')}</p>
<p>${_('
Credentials
and options for api.sickrage.ca')}</p>
</div>
<fieldset class="col-lg-9 col-md-8 col-sm-8 col-xs-12 tab-pane-list">
...
...
@@ -45,7 +45,7 @@
<div id="content_use_api">
<div class="row field-pair">
<div class="col-lg-3 col-md-4 col-sm-5 col-xs-12">
<label class="component-title">${_('API
p
rovider
c
ache')}</label>
<label class="component-title">${_('API
P
rovider
C
ache')}</label>
</div>
<div class="col-lg-9 col-md-8 col-sm-7 col-xs-12 component-desc">
<input type="checkbox" class="enabler" name="enable_api_providers_cache"
...
...
@@ -56,16 +56,16 @@
<div class="row field-pair">
<div class="col-lg-3 col-md-4 col-sm-5 col-xs-12">
<label class="component-title">${_('API
username
')}</label>
<label class="component-title">${_('API
Client ID
')}</label>
</div>
<div class="col-lg-9 col-md-8 col-sm-7 col-xs-12 component-desc">
<div class="input-group input350">
<div class="input-group-addon">
<span class="glyphicon glyphicon-user"></span>
</div>
<input name="api_
username
" id="api_
username
"
value="${sickrage.app.config.api_
username
}"
title="API
username
"
<input name="api_
client_id
" id="api_
client_id
"
value="${sickrage.app.config.api_
client_id
}"
title="API
Client ID
"
class="form-control"
autocapitalize="off"/>
</div>
...
...
@@ -74,16 +74,16 @@
<div class="row field-pair">
<div class="col-lg-3 col-md-4 col-sm-5 col-xs-12">
<label class="component-title">${_('API
password
')}</label>
<label class="component-title">${_('API
Client Secret
')}</label>
</div>
<div class="col-lg-9 col-md-8 col-sm-7 col-xs-12 component-desc">
<div class="input-group input350">
<div class="input-group-addon">
<span class="glyphicon glyphicon-lock"></span>
</div>
<input type="password" name="api_
password" id="api_password
"
value="${sickrage.app.config.api_
password
}"
title="API
password
"
<input type="password" name="api_
client_secret" id="api_client_secret
"
value="${sickrage.app.config.api_
client_secret
}"
title="API
Client Secret
"
class="form-control"
autocapitalize="off"/>
</div>
...
...
sickrage/version.txt
View file @
92752289
9.2.5
\ No newline at end of file
9.2.7
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment