在application.properties中,我需要设置OAuth2密钥...
OAuth2AppClientId=AB............................AN
OAuth2AppClientSecret=br................................u8
OAuth2AppRedirectUri=http://localhost:8085/oauth2redirect
最初,我将键放在“”引号中,假设它们应被视为字符串,但要使其正常工作,我必须将其删除。有人可以解释怎么回事
OAuth2AppClientId=AB............................AN when I build the app
以及如何找到有关OAuth2AppClientId的更多信息?
Google搜索可能是从这里开始的地方。以下是有关Client ID
和Client Secret
是什么的大量资源:
The client_id is a public identifier for apps.
The client_secret is a secret known only to the application and the authorization server.
ton
Client ID
是Intuit标识其您的应用
string
。但是,当您的应用程序通过QuickBooks Online进行身份验证时,您的应用程序会将Client ID
发送到QuickBooks,以便QuickBooks知道它是您的应用程序试图授权与QuickBooks的连接,而不是其他应用程序的授权。 OAuth2PlatformClientFactory
@Service
@PropertySource(value="classpath:/application.properties", ignoreResourceNotFound=true)
public class OAuth2PlatformClientFactory {
@Autowired
org.springframework.core.env.Environment env;
OAuth2PlatformClient client;
OAuth2Config oauth2Config;
@PostConstruct
public void init() {
// intitialize a single thread executor, this will ensure only one thread processes the queue
oauth2Config = new OAuth2Config.OAuth2ConfigBuilder(env.getProperty("OAuth2AppClientId"), env.getProperty("OAuth2AppClientSecret")) //set client id, secret
.callDiscoveryAPI(Environment.SANDBOX) // call discovery API to populate urls
.buildConfig();
client = new OAuth2PlatformClient(oauth2Config);
}
public OAuth2PlatformClient getOAuth2PlatformClient() {
return client;
}
public OAuth2Config getOAuth2Config() {
return oauth2Config;
}
public String getPropertyValue(String propertyName) {
return env.getProperty(propertyName);
}
}
https://github.com/IntuitDeveloper/OAuth2-JavaWithSDK/blob/master/src/main/java/com/intuit/developer/sampleapp/oauth2/client/OAuth2PlatformClientFactory.java