-
-
Save sbogomolov/708eba479c61b0bc0ada18aad5b2c544 to your computer and use it in GitHub Desktop.
from authentik.sources.plex.models import UserPlexSourceConnection | |
import json | |
connection = UserPlexSourceConnection.objects.filter(user=request.user).first() | |
if not connection: | |
ak_logger.info("Overseer: No Plex connection found") | |
return {} | |
base_url = "http://overseerr.apps:5055" | |
end_point = "/api/v1/auth/plex" | |
headers = { | |
"Content-Type": "application/json", | |
} | |
data = { | |
"authToken": connection.plex_token | |
} | |
response = requests.post(base_url + end_point, headers=headers, data=json.dumps(data)) | |
if response.status_code == 200: | |
sid_value = response.cookies.get("connect.sid") | |
cookie_obj = f"connect.sid={sid_value}" | |
ak_logger.info("Overseer: Successfully authenticated with Plex token") | |
return { | |
"ak_proxy": { | |
"user_attributes": { | |
"additionalHeaders": { | |
"Cookie": cookie_obj | |
} | |
} | |
} | |
} | |
else: | |
ak_logger.error(f"Overseer: The request failed with: {response.text}") | |
return {} |
When logged in to authentik, go to settings (cogwheel in the top right), then Connected Services. You should see Plex there. You can click Connect and log in with the Plex account that will be associated with the currently logged in authentik user.
Thank you so much for that! :) Makes much more sense and I can now see the output that is expected!
@imightbelosthere I’m glad it worked for you :)
Well... sort'a worked... I'm having the same situation as others which is the fact that I get to the overseerr page and it prompts me for the login instead of SSO'ing using the connected service.
On my overseerr.yml file I have the following:
Then on the Proxy Provider I have:
What am I doing wrong here?
Do you have that custom scope selected?
custom scope... ??? Pardon my ignorance... Where exactly?
You should’ve created a custom scope mapping (code in the first post). Then you need to use this custom scope mapping in your proxy provider. You should see it in the right list Selected Scopes
.
You should’ve created a custom scope mapping (code in the first post). Then you need to use this custom scope mapping in your proxy provider. You should see it in the right list
Selected Scopes
.
🤦 That's just it... I've created the Scope Mapping as a Plex Source Mapping!
I have it now on the Proxy Provider, still I land on the login page... hmmmm...
Try incognito tab. If it works there - clear browsing history.
Try incognito tab. If it works there - clear browsing history.
Damn... Right on the money! It works perfectly now! Thanks!!!! :)
You’re most welcome.
When logged in to authentik, go to settings (cogwheel in the top right), then Connected Services. You should see Plex there. You can click Connect and log in with the Plex account that will be associated with the currently logged in authentik user.