示例#1
0
        public async Task <IActionResult> OAuth(bool wizard)
        {
            //https://app.plex.tv/auth#?forwardUrl=http://google.com/&clientID=Ombi-Test&context%5Bdevice%5D%5Bproduct%5D=Ombi%20SSO&pinID=798798&code=4lgfd
            // Plex OAuth
            // Redirect them to Plex
            // We need a PIN first
            var pin = await _plexOAuthManager.RequestPin();

            Uri url;

            if (!wizard)
            {
                url = await _plexOAuthManager.GetOAuthUrl(pin.id, pin.code);
            }
            else
            {
                var websiteAddress = $"{this.Request.Scheme}://{this.Request.Host}{this.Request.PathBase}";
                url = _plexOAuthManager.GetWizardOAuthUrl(pin.id, pin.code, websiteAddress);
            }

            if (url == null)
            {
                return(new JsonResult(new
                {
                    error = "Application URL has not been set"
                }));
            }

            return(new JsonResult(new { url = url.ToString() }));
        }