如何通过OAuth2.0认证方式建立ServiceNow与Salesforce通信

  1. 获取Salesforce的Client ID和Client Secret
    在salesforce页面中找到Stepup>Build>Create>Apps,在Connected Apps处点New为自己的SN添加链接。
    Consumer Key和Consumer Secret即是Client ID和Client Secret。
    注意:Callback URL必须设置。即https://YourInstanceName.service-now.com/oauth_redirect.do。
    此处只讲解OAuth2.0正统的Authorization Code模式。
    当然如果要使用OAuth2.0的PWD模式可以再点击Edit进去将IP Restriction修改为Relax IP Restriction
    如何通过OAuth2.0认证方式建立ServiceNow与Salesforce通信

2.在SN中创建OAuth Entity
打开Application Registry点击New,选择使用第三方OAuth Provider。按照下图填写并保存。
注意:如果你使用的是沙盒模式,请把login.salesforce切换成test.salesforce.

如何通过OAuth2.0认证方式建立ServiceNow与Salesforce通信

保存完毕之后系统会自动生成OAuth Entity Profiles,这个时候需要注意的是,它和Entity的Grent Type必须一致。

  1. 在Rest Message中测试
    创建一个新的Rest Message将其Endpoint设置为https://login.salesforce.com/services/oauth2/token
    Authentication选择Oauth2.0并且选择刚才生成的profile并保存。保存完毕之后会出现Get OAuth Token这个UI Action。点击输入账户密码或者session没过期可以直接选择User。
    如何通过OAuth2.0认证方式建立ServiceNow与Salesforce通信

成功后如图显示:
如何通过OAuth2.0认证方式建立ServiceNow与Salesforce通信

猜你喜欢

转载自blog.51cto.com/13716461/2170149