Skip to content

Commit 700b0c5

Browse files
committed
Added trakt token refresh.
1 parent 09c2657 commit 700b0c5

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

RadarrAPI/Controllers/TraktController.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,25 @@ public async Task<IActionResult> TraktCallback([FromQuery(Name = "code")] string
6969
return BadRequest("Received trakt token was invalid.");
7070
}
7171

72-
return Redirect($"{traktEntity.Target}?oauth={traktAuth.AccessToken}&refresh={traktAuth.RefreshToken}");
72+
return Redirect($"{traktEntity.Target}?access={traktAuth.AccessToken}&refresh={traktAuth.RefreshToken}");
73+
}
74+
75+
[Route("refresh")]
76+
[HttpGet]
77+
public async Task<IActionResult> TraktCallback([FromQuery(Name = "refresh")] string refresh)
78+
{
79+
if (string.IsNullOrWhiteSpace(refresh))
80+
{
81+
return BadRequest("Invalid refresh code specified.");
82+
}
83+
84+
var traktAuth = await _trakt.OAuth.RefreshAuthorizationAsync(refresh, _trakt.ClientId, _trakt.ClientSecret, GetRedirectUri());
85+
if (!traktAuth.IsValid)
86+
{
87+
return BadRequest("Received trakt token was invalid.");
88+
}
89+
90+
return Ok(traktAuth);
7391
}
7492

7593
private string GetRedirectUri()

0 commit comments

Comments
 (0)