mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-23 06:45:19 -07:00
an updated radarrAPI has been deployed --> this commit makes
trakt authentication ready to be merged to the develop branch
This commit is contained in:
parent
aa977eb2d5
commit
f138d4f677
2 changed files with 8 additions and 18 deletions
|
@ -11,16 +11,11 @@ namespace NzbDrone.Core.NetImport.Trakt
|
||||||
{
|
{
|
||||||
public class refreshRequestResponse
|
public class refreshRequestResponse
|
||||||
{
|
{
|
||||||
//the next 3 lines can eventually be removed and replaced with the ones marked below
|
public string access_token { get; set; }
|
||||||
public bool success { get; set; }
|
|
||||||
public string oauth { get; set; }
|
|
||||||
public string refresh { get; set; }
|
|
||||||
/*//replace with the lines below when radarrAPI changes have been merged
|
|
||||||
public string access_token { get; set; }
|
|
||||||
public string token_type { get; set; }
|
public string token_type { get; set; }
|
||||||
public int expires_in { get; set; }
|
public int expires_in { get; set; }
|
||||||
public string refresh_token { get; set; }
|
public string refresh_token { get; set; }
|
||||||
public string scope { get; set; }*/
|
public string scope { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class TraktRequestGenerator : INetImportRequestGenerator
|
public class TraktRequestGenerator : INetImportRequestGenerator
|
||||||
|
@ -94,9 +89,7 @@ namespace NzbDrone.Core.NetImport.Trakt
|
||||||
|
|
||||||
if ( unixTime > _configService.TraktTokenExpiry)
|
if ( unixTime > _configService.TraktTokenExpiry)
|
||||||
{
|
{
|
||||||
//the next line should eventually be removed and replaced with the one commented out below it
|
var url = "http://radarr.aeonlucid.com/v1/trakt/refresh?refresh="+_configService.TraktRefreshToken;
|
||||||
var url = "https://api.couchpota.to/authorize/trakt_refresh?token="+_configService.TraktRefreshToken;
|
|
||||||
//var url = "https://radarr.aeonlucid.com/authorize/trakt_refresh?token="+_configService.TraktRefreshToken;
|
|
||||||
|
|
||||||
HttpWebRequest rquest = (HttpWebRequest)WebRequest.Create(url);
|
HttpWebRequest rquest = (HttpWebRequest)WebRequest.Create(url);
|
||||||
string rsponseString = string.Empty;
|
string rsponseString = string.Empty;
|
||||||
|
@ -107,8 +100,8 @@ namespace NzbDrone.Core.NetImport.Trakt
|
||||||
rsponseString = reader.ReadToEnd();
|
rsponseString = reader.ReadToEnd();
|
||||||
}
|
}
|
||||||
refreshRequestResponse j1 = Newtonsoft.Json.JsonConvert.DeserializeObject<refreshRequestResponse>(rsponseString);
|
refreshRequestResponse j1 = Newtonsoft.Json.JsonConvert.DeserializeObject<refreshRequestResponse>(rsponseString);
|
||||||
_configService.TraktAuthToken = j1.oauth; //eventually replace with j1.access_token
|
_configService.TraktAuthToken = j1.access_token;
|
||||||
_configService.TraktRefreshToken = j1.refresh; //eventually replace with j1.refresh_token
|
_configService.TraktRefreshToken = j1.refresh_token;
|
||||||
|
|
||||||
//lets have it expire in 8 weeks (4838400 seconds)
|
//lets have it expire in 8 weeks (4838400 seconds)
|
||||||
_configService.TraktTokenExpiry = unixTime + 4838400;
|
_configService.TraktTokenExpiry = unixTime + 4838400;
|
||||||
|
@ -122,9 +115,7 @@ namespace NzbDrone.Core.NetImport.Trakt
|
||||||
|
|
||||||
var request = new NetImportRequest($"{link}", HttpAccept.Json);
|
var request = new NetImportRequest($"{link}", HttpAccept.Json);
|
||||||
request.HttpRequest.Headers.Add("trakt-api-version", "2");
|
request.HttpRequest.Headers.Add("trakt-api-version", "2");
|
||||||
//request.HttpRequest.Headers.Add("trakt-api-key", "657bb899dcb81ec8ee838ff09f6e013ff7c740bf0ccfa54dd41e791b9a70b2f0"); //radarr
|
request.HttpRequest.Headers.Add("trakt-api-key", "964f67b126ade0112c4ae1f0aea3a8fb03190f71117bd83af6a0560a99bc52e6"); //aeon
|
||||||
//the line below should eventually be replaced with the one commented out above
|
|
||||||
request.HttpRequest.Headers.Add("trakt-api-key", "8a54ed7b5e1b56d874642770ad2e8b73e2d09d6e993c3a92b1e89690bb1c9014"); //couchpotato
|
|
||||||
if (_configService.TraktAuthToken != null)
|
if (_configService.TraktAuthToken != null)
|
||||||
{
|
{
|
||||||
request.HttpRequest.Headers.Add("Authorization", "Bearer " + _configService.TraktAuthToken);
|
request.HttpRequest.Headers.Add("Authorization", "Bearer " + _configService.TraktAuthToken);
|
||||||
|
|
|
@ -27,7 +27,7 @@ var view = Marionette.ItemView.extend({
|
||||||
|
|
||||||
onShow : function() {
|
onShow : function() {
|
||||||
var params = new URLSearchParams(window.location.search);
|
var params = new URLSearchParams(window.location.search);
|
||||||
var oauth = params.get('oauth');
|
var oauth = params.get('access');
|
||||||
var refresh=params.get('refresh');
|
var refresh=params.get('refresh');
|
||||||
if (oauth && refresh){
|
if (oauth && refresh){
|
||||||
history.pushState('object', 'title', callback_url);
|
history.pushState('object', 'title', callback_url);
|
||||||
|
@ -111,8 +111,7 @@ var view = Marionette.ItemView.extend({
|
||||||
|
|
||||||
_resetTraktTokens : function() {
|
_resetTraktTokens : function() {
|
||||||
if (window.confirm("Proceed to trakt.tv for authentication?\nYou will then be redirected back here.")){
|
if (window.confirm("Proceed to trakt.tv for authentication?\nYou will then be redirected back here.")){
|
||||||
window.location='https://api.couchpota.to/authorize/trakt/?target='+callback_url; //this eventually can be removed and replaced with the line below
|
window.location='http://radarr.aeonlucid.com/v1/trakt/redirect?target='+callback_url;
|
||||||
//window.location='https://radarr.aeonlucid.com/authorize/trakt?target='+callback_url;
|
|
||||||
//this.ui.resetTokensButton.hide();
|
//this.ui.resetTokensButton.hide();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue