我正在尝试访问新的REST API,以构建服务器到服务器接口,以将CRM与其他应用程序(如网店等)集成.
我尝试了从Azure AD获取访问令牌的两种方法:
客户凭证
import adal
token_response = adal.acquire_token_with_client_credentials(
'https://login.microsoftonline.com/abcdefgh-1234-5678-a1b1-morerandomstuff',
client_id,
secret
)
Run Code Online (Sandbox Code Playgroud)
和用户/密码
import adal
token_response = adal.acquire_token_with_username_password(
'https://login.microsoftonline.com/abcdefgh-1234-5678-a1b1-morerandomstuff',
'interface@crm.my_domain.com',
'my_password'
)
Run Code Online (Sandbox Code Playgroud)
在这两种情况下,token_response都会获得一个token-object,包含accessToken,refreshToken,expiresIn等.所以我认为到目前为止还没有错误.
然后我尝试向Web API发出一个简单的请求:
headers = {'Authorization': '%s %s' % (token_response.get('tokenType'),
token_response.get('accessToken'))}
r = requests.get('https://domain.api.crm4.dynamics.com/api/data/v8.0/Product',
headers=headers)
Run Code Online (Sandbox Code Playgroud)
这总是返回HTTP 401 - 未授权:访问被拒绝.
('WWW-Authenticate', 'Bearer error=invalid_token,
error_description=Error during token validation!,
authorization_uri=https://login.windows.net/eabcdefgh-1234-5678-a1b1-morerandomstuff/oauth2/authorize,
resource_id=https://domain.api.crm4.dynamics.com/')
Run Code Online (Sandbox Code Playgroud)
尝试发出请求的用户具有Office-365-Administrator权限,并且在CRM中具有所有管理员角色和管理员角色.根据我的口味,这甚至有点多,但我在某处读到,用户必须拥有office-365管理员权限.在Azure AD中,配置了一个应用程序,该应用程序具有对CRM的"委派权限"("作为组织用户访问CRM Online").
我在这里错过了什么?或者我的REST-get-request错了?新API的Microsoft文档几乎不存在 - 每当您单击某个链接时,您将获得旧API(组织API等)的文档
现在这花了我一些时间来弄清楚,所以我会自我回答。我想在 Django 视图上禁用一个特定页面的浏览器缓存。如果视图是一个函数,则有一些如何执行此操作的信息,但如果它是一个类,则没有。我不想使用中间件,因为只有一个我不想缓存的特定视图。
我有一个 Spring Boot 应用程序,我想用 Selenium 进行测试。我正在使用 WebDriverManager v5.0.3
设置 WebDriver 时WebDriverManager.chromedriver().setup();出现异常:
java.lang.NoClassDefFoundError: org/openqa/selenium/internal/Require
Run Code Online (Sandbox Code Playgroud)
或者
java.lang.ClassNotFoundException: org.openqa.selenium.internal.FindsById
Run Code Online (Sandbox Code Playgroud)
我的 pom.xml 包含以下内容:
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>5.0.3</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-api</artifactId>
<version>4.1.0</version>
</dependency>
Run Code Online (Sandbox Code Playgroud) selenium selenium-webdriver webdriver-manager webdrivermanager-java
我需要在FacesServlet启动时运行一些代码,但是当FacesServlet被声明为final时,我无法扩展它并覆盖init()方法.
特别是,在hibernate删除并创建数据模型之后,我想在开发和测试期间将一些数据写入数据库.
有没有办法配置Faces来运行某些方法,例如在faces-config.xml中?或者最好创建一个执行初始化的单例bean?
当您在 Vaadin v21 中创建网格组件并切换到多选模式时,顶部会有一个“全选”复选框。如何禁用它?网格的默认行为似乎不同,因此 Vaadin 版本之间的解决方案也不同。
Grid<Person> grid = new Grid<>(Person.class, false);
grid.setSelectionMode(Grid.SelectionMode.MULTI);
grid.setItems(personRepository.findAll());
Run Code Online (Sandbox Code Playgroud) 我在 CentOS 上设置 LDAP 服务器时遇到了某种死锁。我使用 /etc/openldap/slapd.d 下的在线配置文件 文档告诉你不要手动修改这些文件,并且这些文件是校验和的。但我无法使用 ldapmodify,因为我无法登录(简单绑定) - 而且我无法登录,因为我无法为用户设置密码 - 而且我无法为用户设置密码,因为我无法使用 ldapmodify,因为我无法登录,因为我无法设置密码,因为......
我当然可以通过直接编辑文件来设置它 - 我已经做到了,而且它有效。但这只是让我烦恼,我找不到一种“正确”的方法。