authlete的python库

authlete的Python项目详细描述


python的authlete库

概述

这是authlete的官方python库 网络API。

许可证

apache许可证,2.0版

源代码

https://github.com/authlete/authlete-python

pypi(python包索引)

https://pypi.org/project/authlete/

安装

pip install authlete

快速启动

下面的代码模拟"授权代码流"。替换客户机id, service_api_keyservice_api_secret中的代码。 代码假定客户端应用程序的客户端类型是"public" (否则,令牌端点将需要客户端身份验证)和 注册的重定向uri的数目是一个(否则redirect\u urirequest 参数是必需的)。

fromauthlete.apiimport*fromauthlete.confimport*fromauthlete.dtoimport*#--------------------------------------------------# Your Configuration#--------------------------------------------------authlete_api_server='https://api.authlete.com'service_api_key='SERVICE_API_KEY'service_api_secret='SERVICE_API_SECRET'client_id='CLIENT_ID'user_id='USER_ID'#--------------------------------------------------# AuthleteApi#--------------------------------------------------# Configuration to access Authlete APIs.cnf=AuthleteConfiguration()cnf.baseUrl=authlete_api_servercnf.serviceApiKey=service_api_keycnf.serviceApiSecret=service_api_secret# Authlete API callerapi=AuthleteApiImpl(cnf)#--------------------------------------------------# /api/auth/authorization API#--------------------------------------------------# Prepare a request to /api/auth/authorization API.req=AuthorizationRequest()req.parameters='response_type=code&client_id={}'.format(client_id)# Call /api/auth/authorization API. The class of the# response is authlete.dto.AuthorizationResponse.res=api.authorization(req)#--------------------------------------------------# /api/auth/authorization/issue API#--------------------------------------------------# Prepare a request to /api/auth/authorization/issue API.req=AuthorizationIssueRequest()req.ticket=res.ticketreq.subject=user_id# Call /api/auth/authorization/issue API. The class of the# response is authlete.dto.AuthorizationIssueResponse.res=api.authorizationIssue(req)# An authorization response returned to the user agent.print('HTTP/1.1 302 Found')print('Location: {}'.format(res.responseContent))#--------------------------------------------------# /api/auth/token API#--------------------------------------------------# Prepare a request to /api/auth/token API.req=TokenRequest()req.parameters='client_id={}&grant_type=authorization_code&code={}'\
    .format(client_id,res.authorizationCode)# Call /api/auth/token API. The class of the response is# authlete.dto.TokenResponse.res=api.token(req)# A token response returned to the client.print("\nHTTP/1.1 200 OK")print("Content-Type: application/json\n")print(res.responseContent)

说明

如何获取authleteapi

所有与authlete web api通信的方法都收集在 authlete.api.authleteapi接口。authlete.api.authleteapiimpl类是 接口的唯一实现。authleteapiimpl的构造函数 类需要一个authlete.conf.authleteConfiguration类的实例。

# Prepare an instance of AuthleteConfiguration.cnf=AuthleteConfiguration()cnf.baseUrl=...cnf.serviceOwnerApiKey=...cnf.serviceOwnerApiSecret=...cnf.serviceApiKey=...cnf.serviceApiSecret=...# Get an implementation of AuthleteApi interface.api=AuthleteApiImpl(cnf)

authleteconfiguration类有两个子类,authleteevconfiguration 以及authleteinconfiguration

authletenvconfiguration类从以下环境读取设置 变量。

  • 授权基本URL
  • 授权服务所有者apikey
  • 授权服务所有者APISecret
  • 授权服务apikey
  • 授权服务APISecret

authletenvconfiguration的构造函数读取环境变量, 所以在python代码中,您所要做的就是创建 按如下方式分类。

cnf=AuthleteEnvConfiguration()

另一方面,authleteinconfiguration类读取ini文件。这个 文件的格式authleteinconfiguration预期如下。

[authlete]base_url=...service_owner.api_key=...service_owner.api_secret=...service.api_key=...service.api_secret=...

authleteinconfiguration的构造函数接受可选参数 它表示ini文件的名称。如果省略了参数, authlete.ini用作默认文件。如果您的ini文件名是 不是authlete.ini,而是按如下方式将文件名显式传递给构造函数。

cnf=AuthleteIniConfiguration('configuration.ini')

authleteapi设置

getsettings()方法的authleteapi接口返回 authlete.api.settings类。可以设置连接超时和读取超时 通过实例。

settings=api.getSettings()settings.connectionTimeout=5.0settings.readTimeout=5.0

authleteapi方法类别

authleteapi接口中的方法可以分为一些类别。

实现授权端点的方法
  • 授权(请求)
  • 授权失败(请求)
  • 授权问题(请求)
令牌端点实现方法
  • 令牌(请求)
  • 令牌失败(请求)
  • 令牌颁发(请求)
服务管理方法
  • 创建服务(服务)
  • 删除服务(serviceapikey)
  • getservice(serviceapikey)
  • getservicelist(开始=无,结束=无)
  • 更新服务(服务)
客户应用程序管理方法
  • createclient(客户端)
  • 删除客户端(clientid)
  • getclient(clientid)
  • <代码>getclientlist(developer=none,start=none,end=none)
  • 更新客户端(客户端)
  • 刷新clientsecret(clientid)
  • 更新客户端机密(clientid,clientsecret)
访问令牌内省的方法
  • 自省(请求)
  • 标准自省(请求)
  • getTokenList(clientIdentifier=none,subject=none,start=none,end=none)
撤销端点实现方法
  • 撤销(请求)
实现用户信息端点的方法
  • 用户信息(请求)
  • 用户信息问题(请求)
jwk set端点实现方法
  • getServiceJWKS(pretty=true,includePrivateKeys=false)
openid connect发现方法
  • getserviceconfiguration(pretty=true)
代币操作方法
  • 令牌创建(请求)
  • 令牌更新(请求)
每个客户端可请求作用域的方法(已弃用;客户端api足够了)
  • getrequestablescopes(clientid)
  • setrequestablescopes(clientid,scopes)
  • deleterequestablescopes(clientid)
授予范围的记录方法
  • getgrantedscopes(clientid,subject)
  • deletegrantedscopes(clientid,subject)
基于用户-客户组合的授权管理方法
  • 删除客户端授权(clientid,subject)
  • getclientauthorizationlist(请求)
  • 更新客户端授权(clientid,请求)
何塞的方法
  • verifyjose(请求)
CIBA的方法(客户发起的反向认证)
  • 反向通道身份验证(请求)
  • 反向通道身份验证问题(请求)
  • 反向通道身份验证失败(请求)
  • BackchannelAuthenticationComplete(请求)
openid connect动态客户端注册方法
  • dynamicclientregister(请求)
  • dynamicclientget(请求)
  • dynamicclientupdate(请求)
  • 动态客户端删除(请求)
设备流程方法
  • 设备授权(请求)
  • 设备完成(请求)
  • 设备验证(请求)

authlete版本

一些api和特性不起作用(即使它们是在authleteapi中定义的)。 接口)如果您使用的authlete api服务器不支持它们。例如, Ciba只在Authlete2.1以后的版本中工作。如果您想使用,请联系我们 更新的authlete版本。

Authlete 2.0及以后版本中提供的功能:

  • 金融级API(FAPI)
  • OAuth 2.0相互TLS客户端身份验证和证书绑定访问令牌(MTL)
  • 基于JWT的客户端身份验证(RFC 7523)
  • 范围属性
  • 英国公开银行安全简介

Authlete 2.1及以后版本中提供的功能:

  • 客户端启动的反向通道身份验证(CIBA)
  • OAuth 2.0的JWT安全授权响应模式(JARM)
  • 动态客户端注册(RFC 7591&RFC 7592)
  • OAuth 2.0设备授权授权(设备流)
  • 基于jwt的访问令牌

另请参见

联系人

联系方式:https://www.authlete.com/contact/" rel="nofollow">https://www.authlete.com/contact/

<表><广告>目的 电子邮件地址 < /广告><正文>概述 信息@authlete.com销售 sales@authlete.comprpr@authlete.com技术性支持@authlete.com

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java JTable无法向新创建的列添加值   java如何调整JEditorPane中编辑区域的大小?   Java通过反射确定未知数组中的数组大小   java Intellij Idea有时无法按其预期的方式构建应用程序   java Swing GUI带有IntelliJ错误“contentPane不能设置为null”从终端编译时   如何将这些通用方法调用从C#转换为Java   在null上找不到java属性或字段“index”   从Java HashMap获取整数值时是否需要调用intValue()方法?   java Android谷歌地图获取相机中的图像块   unix无法捕获JAVA中“who m”命令的输出   java,同时将邮件发送到“收件人”标题“我”中的多个收件人   在java中向链表添加未知数量的节点   无法为Heroku上的discord bot设置java端口   java使用Apache HttpClient进行选项请求   与元素类型“ApplicationName”关联的属性“Application Version”需要java Open quote   Android Studio Java中的两个变量求和