an updated radarrAPI has been deployed --> this commit makes

trakt authentication ready to be merged to the develop branch
pull/2/head
geogolem 8 years ago
parent aa977eb2d5
commit f138d4f677

@ -11,16 +11,11 @@ namespace NzbDrone.Core.NetImport.Trakt
{
public class refreshRequestResponse
{
//the next 3 lines can eventually be removed and replaced with the ones marked below
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 access_token { get; set; }
public string token_type { get; set; }
public int expires_in { get; set; }
public string refresh_token { get; set; }
public string scope { get; set; }*/
public string scope { get; set; }
}
public class TraktRequestGenerator : INetImportRequestGenerator
@ -94,9 +89,7 @@ namespace NzbDrone.Core.NetImport.Trakt
if ( unixTime > _configService.TraktTokenExpiry)
{
//the next line should eventually be removed and replaced with the one commented out below it
var url = "https://api.couchpota.to/authorize/trakt_refresh?token="+_configService.TraktRefreshToken;
//var url = "https://radarr.aeonlucid.com/authorize/trakt_refresh?token="+_configService.TraktRefreshToken;
var url = "http://radarr.aeonlucid.com/v1/trakt/refresh?refresh="+_configService.TraktRefreshToken;
HttpWebRequest rquest = (HttpWebRequest)WebRequest.Create(url);
string rsponseString = string.Empty;
@ -107,8 +100,8 @@ namespace NzbDrone.Core.NetImport.Trakt
rsponseString = reader.ReadToEnd();
}
refreshRequestResponse j1 = Newtonsoft.Json.JsonConvert.DeserializeObject<refreshRequestResponse>(rsponseString);
_configService.TraktAuthToken = j1.oauth; //eventually replace with j1.access_token
_configService.TraktRefreshToken = j1.refresh; //eventually replace with j1.refresh_token
_configService.TraktAuthToken = j1.access_token;
_configService.TraktRefreshToken = j1.refresh_token;
//lets have it expire in 8 weeks (4838400 seconds)
_configService.TraktTokenExpiry = unixTime + 4838400;
@ -122,9 +115,7 @@ namespace NzbDrone.Core.NetImport.Trakt
var request = new NetImportRequest($"{link}", HttpAccept.Json);
request.HttpRequest.Headers.Add("trakt-api-version", "2");
//request.HttpRequest.Headers.Add("trakt-api-key", "657bb899dcb81ec8ee838ff09f6e013ff7c740bf0ccfa54dd41e791b9a70b2f0"); //radarr
//the line below should eventually be replaced with the one commented out above
request.HttpRequest.Headers.Add("trakt-api-key", "8a54ed7b5e1b56d874642770ad2e8b73e2d09d6e993c3a92b1e89690bb1c9014"); //couchpotato
request.HttpRequest.Headers.Add("trakt-api-key", "964f67b126ade0112c4ae1f0aea3a8fb03190f71117bd83af6a0560a99bc52e6"); //aeon
if (_configService.TraktAuthToken != null)
{
request.HttpRequest.Headers.Add("Authorization", "Bearer " + _configService.TraktAuthToken);

@ -27,7 +27,7 @@ var view = Marionette.ItemView.extend({
onShow : function() {
var params = new URLSearchParams(window.location.search);
var oauth = params.get('oauth');
var oauth = params.get('access');
var refresh=params.get('refresh');
if (oauth && refresh){
history.pushState('object', 'title', callback_url);
@ -111,8 +111,7 @@ var view = Marionette.ItemView.extend({
_resetTraktTokens : function() {
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='https://radarr.aeonlucid.com/authorize/trakt?target='+callback_url;
window.location='http://radarr.aeonlucid.com/v1/trakt/redirect?target='+callback_url;
//this.ui.resetTokensButton.hide();
}
},

Loading…
Cancel
Save