简体   繁体   English

无法从Salesforce获取刷新令牌

[英]Not getting refresh token from Salesforce

I have been using Force.com Toolkit for .NET for long time. 我已经将Force.com Toolkit用于.NET很长时间了。 Recently one of a client has started complaining for session invalid issue. 最近,一位客户开始投诉会话无效问题。 So I started digging up and found that I have to refresh token by calling TokenRefreshAsync for which I need to pass on refresh token which I get during authentication. 因此,我开始进行挖掘,发现我必须通过调用TokenRefreshAsync来刷新令牌, 为此我需要传递在身份验证期间获取的刷新令牌。 But I am getting null refresh token from SF. 但是我从SF获取空刷新令牌。

I have tried everything possible thing I found on the internet without any success. 我尝试了在互联网上找到的所有可能的尝试,但都没有成功。 Perform requests on your behalf at any time (refresh_token, offline_access) is added in OAuth Scopes: OAuth范围中随时添加了代表您执行请求(refresh_token,offline_access)

在此处输入图片说明

Refresh token expiry is set at 2 days: 刷新令牌的有效期设置为2天:

在此处输入图片说明

This is the simple code I am using to authenticate: 这是我用来验证的简单代码:

var task = authClient.UsernamePasswordAsync(consumerKey, consumerSecret, username, password, callback);
task.Wait();

What am I missing here? 我在这里想念什么?

The Username-Password Oauth Flow does not provide a refresh token on Salesforce, regardless of scopes: 无论范围如何, 用户名-密码Oauth流都不会在Salesforce上提供刷新令牌:

This OAuth authentication flow passes the user's credentials back and forth. 此OAuth身份验证流程来回传递用户的凭据。 Use this authentication flow only when necessary. 仅在必要时使用此身份验证流程。 No refresh token is issued. 没有发出刷新令牌。

If you want a refresh token, you'll need to implement a different OAuth flow (preferable!), or eschew the refresh token and reauthenticate when your access token expires. 如果您需要刷新令牌,则需要实施其他OAuth流(首选!),或者避免访问刷新令牌并在访问令牌过期时重新进行身份验证。 The latter makes you vulnerable to credential and security token changes on the part of the authenticated user, however, which using a more suitable OAuth flow grants resilience against. 后者使您容易受到身份验证的用户的凭据和安全令牌更改的影响,但是,使用更合适的OAuth流可以授予其弹性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 通过REST API从OAuth.io获取刷新令牌 - Getting a refresh token from OAuth.io through REST API 获取OAuth2刷新令牌 - Getting OAuth2 refresh token 从代码中刷新客户端的身份令牌 - Refresh identity token from client from code 在IdentityServer3中使用刷新令牌时获取NullReferenceException - Getting NullReferenceException when using refresh token in IdentityServer3 无法从使用旧刷新令牌调用的授权类型refresh_token的azure AD获取新的刷新令牌 - Not able to get new refresh token from azure AD with grant type refresh_token called with old refresh token 从浏览器获取无效令牌 - Getting Invalid Token from Browser Google OAuth使用JavaScript生成的OAuth access_token获取刷新令牌 - Google OAuth getting refresh token using javascript generated OAuth access_token 获取Salesforce访问令牌时遇到问题。 我有一个邮递员电话,它很有趣,但是在代码中不起作用 - Having a problem getting a salesforce access token. I've got a post man call that works fun, but it's not working in code 如何从Jquery Ajax调用Web Api 2刷新令牌 - how to call Web Api 2 Refresh Token from the Jquery Ajax 后端服务的OAuth2访问和刷新令牌 - OAuth2 Access and Refresh Token from backend service
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM