Как интегрировать аутентификацию Oracle IDCS с Python FastAPIPython

Программы на Python
Ответить
Anonymous
 Как интегрировать аутентификацию Oracle IDCS с Python FastAPI

Сообщение Anonymous »

Как интегрировать Oracle Identity Manager с Python FastAPI?
Пробовал это с кодом SDK:

Код: Выделить всё

def auth(request): options = getOptions() am = IdcsClient.AuthenticationManager(options) url = am.getAuthorizationCodeUrl(options["redirectURL"], options["scope"], "1234", "code") return HttpResponseRedirect(url)

Код: Выделить всё

# Definition of the /callback route
def callback(request):
code = request.GET.get('code')
#Authentication Manager loaded with the configurations.
am = IdcsClient.AuthenticationManager(getOptions())
#Using the Authentication Manager to exchange the Authorization Code to an Access Token.
ar = am.authorizationCode(code)
#Get the access token as a variable
access_token = ar.getAccessToken()
#User Manager loaded with the configurations.
um = IdcsClient.UserManager(getOptions())
#Using the access_token value to get an object instance representing the User Profile.
u = um.getAuthenticatedUser(access_token)
#Getting the user details in json object format.
displayname = u.getDisplayName()
#The application then adds these information to the User Session.
request.session['access_token'] = access_token
request.session['displayname'] = displayname
#Rendering the home page and adding displayname to be printed in the page.
return render(request, 'sampleapp/home.html', {'displayname': displayname})
Как написать конечные точки API для аутентификации и продолжения успешной аутентификации?
Я пробовал так

Код: Выделить всё

@app.get("/get_data")
def print_data():
auth()
# On success auth Proceed next
Мы хотим, чтобы все наши конечные точки были защищены.
Проблема здесь в том, что даже если аутентификация не удалась, мы все равно продолжаем работу.
Могу ли я Есть пример кода, чтобы понять, как реализовать?

Подробнее здесь: https://stackoverflow.com/questions/792 ... on-fastapi
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Python»