我尝试使用func numberOfComponents(in pickerView: UIPickerView) -> Int {
return 2
}
func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
if component == 0 {
return firstArray.count
}else{
if firstArray[lastSelectedArray] == "Weekly" {
return thirdArray.count
}else if firstArray[lastSelectedArray] == "Daily" {
return thirdArray.count
}else if firstArray[lastSelectedArray] == "Monthly" {
return secondArray.count
}else if firstArray[lastSelectedArray] == "Yearly" {
return fourthArray.count
}
}
return 0
}
func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
if component == 0 {
return firstArray[row]
}else{
if firstArray[lastSelectedArray] == "Weekly" {
return thirdArray[row]
}else if firstArray[lastSelectedArray] == "Daily" {
return thirdArray[row]
}else if firstArray[lastSelectedArray] == "Monthly" {
return secondArray[row]
}else if firstArray[lastSelectedArray] == "Yearly" {
return fourthArray[row ]
}
}
return "undefined"
}
func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
if component == 0 {
lastSelectedArray = row
pickerView.reloadComponent(1)
daysLabel.text = firstArray[row]
}
从Identity Server 3获取凭据。获取一个角色的凭据可以正常工作,但我需要在一个请求中获取两个范围的凭据。范围是" api"和" myrole"。
据我所知,应该通过简单地用空格分隔来完成多个角色,如下所示:
IdentityModel.TokenClient
这会生成一个请求:
var client = new TokenClient(
"https://theidentityserver.com/connect/token",
"myclient",
"mysecret");
var result = await client.RequestClientCredentialsAsync("api myrole");
并产生回应:
{"错误":" invalid_scope"}
如您所见,> POST https://theidentityserver.com/connect/token HTTP/1.1 Connection:
> Keep-Alive Content-Type: application/x-www-form-urlencoded Accept:
> application/json Authorization: Basic [auth token here]
> Content-Length: 46 Host: theidentityserver.com
>
> grant_type=client_credentials&scope=api+myrole
生成一个请求,其中范围由加号而不是空格分隔。有什么方法可以解决这个问题,还是我做错了什么?