Initializing the ConversationService() object in C# if fairly straightforward, but I'm having issues doing the same in F#. When I run the code below, I get a Parameter name: versionDate cannot be null. Use 'CONVERSATION_VERSION_DATE_2017_05_26' error.
I've tried manually adding "versionDate": "2017-05-26" and "version_date": "2017-05-26" to the credential string, but it is still producing the same error.
Is there a way I can pass the version date correctly to the ConversationService object to avoid this null pointer exception?
C# Version
ConversationService service = new ConversationService( <username> , <password> , ConversationService.CONVERSATION_VERSION_DATE_2017_05_26);
F# Version
let credential = """
{
"url": "https://gateway.watsonplatform.net/conversation/api",
"username": "xxxxxxxxxxxxxx",
"password": "xxxxxxxxxxxxxx"
}
"""
let workspaceID = "xxxxxxxxxxxxxx"
let service = new ConversationService()
service.SetCredential credential
Related
I am trying to use AWS CKD (JAVA) to create a DocumentDB instance.
This works with a "simple" plaintext password, but fails when I try to use a DatabaseSecret and a password stored in Secrets Manager.
The error I get is this:
1:44:42 PM | CREATE_FAILED | AWS::DocDB::DBCluster | ApiDocDb15EB2C21
The parameter MasterUserPassword is not a valid password. Only printable ASCII characters besides '/', '#', '"', ' ' may
be used. (Service: AmazonRDS; Status Code: 400; Error Code: InvalidParameterValue; Request ID: c786d247-8ff2-4f30-9a8a-5
065fc89d3d1; Proxy: null)
which is clear enough, but it continues to happen, even if I set the password to something such as simplepassword - so I am now somewhat confused as to what am I supposed to fix now.
Here is the code, mostly adapted from the DocDB documentation:
String id = String.format(DOCDB_PASSWORD_ID);
return DatabaseSecret.Builder.create(scope, id)
.secretName(store.getSsmSecretName())
.encryptionKey(passwordKey)
.username(store.getAdminUser())
.build();
where the ssmSecretName is the name of the secret in SecretManager:
└─( aws secretsmanager get-secret-value --secret-id api-db-admin-pwd
ARN: arn:aws:secretsmanager:us-west-2:<ACCT>:secret:api-db-admin-pwd-HHxpFf
Name: api-db-admin-pwd
SecretString: '{"api-db-admin-pwd":"simplepassword"}'
This is the code used to build the DbCluster:
DatabaseCluster dbCluster = DatabaseCluster.Builder.create(scope, id)
.dbClusterName(properties.getDbName())
.masterUser(Login.builder()
.username(properties.getAdminUser())
.kmsKey(passwordKey)
.password(masterPassword.getSecretValue())
.build())
.vpc(vpc)
.vpcSubnets(ISOLATED_SUBNETS)
.securityGroup(dbSecurityGroup)
.instanceType(InstanceType.of(InstanceClass.MEMORY5, InstanceSize.LARGE))
.instances(properties.getReplicas())
.storageEncrypted(true)
.build();
The question I have is: should I use a DatabaseSecret? or just retrieve the password from SM and be done with it?
A sub-question then: what is one supposed to use the DatabaseSecret for then?
(NOTE -- this is the same class, almost, as in the rds package; but here I am using the docdb package)
Thanks for any suggestion!
Turns out that the DatabaseSecret creates a key/value pair as the secret:
{
"username": <value of username()>,
"password": <generated>
}
However, the call to Login.password() completely ingnores this, and treats the whole JSON body as the password (so the " double quotes trip it).
The trick is to use DatabaseSecret.secretValueFromJson("password") in the call to Login.password() and it works just fine.
This is (incidentally) inconsistent with the behavior of rds.DatabaseCluster and the rds.Credentials class behavior (who take a JSON SecretValue and parse it correctly for the "password" field).
Leaving it here in case others stumble on this, as there really is NO information out there.
My development Environment : eclipse java
I would like test a requestJWTuserToken sample, but I'm getting an error.
Test code:
OAuth.OAuthToken oAuthToken = apiClient.requestJWTUserToken(IntegratorKey, userId, scopes, privateKeyBytes, 3600);
Assert.assertNotSame(null, oAuthToken);
apiClient.setAccessToken(oAuthToken.getAccessToken(), oAuthToken.getExpiresIn());
UserInfo userInfo = apiClient.getUserInfo(oAuthToken.getAccessToken());
Assert.assertNotSame(null, userInfo);
Assert.assertNotNull(userInfo.getAccounts());
Assert.assertTrue(userInfo.getAccounts().size() > 0);
Error message:
com.docusign.esign.client.ApiException: Error while requesting an access token:
class OAuthToken {
accessToken: null
tokenType: null
refreshToken: null
expiresIn: 0
at com.docusign.esign.client.ApiClient.requestJWTUserToken(ApiClient.java:719)
at smartsuite.app.util.DocuSignUtil.settingAuthentication(DocuSignUtil.java:112)
what are userid?
I found a admin sendbox at user > API username
enter image description here
This error is sometimes encountered when there is a problem with the RSA private key that you are using in your JWT request. Start by verifying how you are passing your key's private data into the request, if you are reading from a environment variable for example make sure the key's value is contained on a single line, otherwise it might be getting truncated.
If your key spans multiple lines as an environment variable try doing a regular expression find/replace where you replace all newline \n characters with the string literal "\n" and then pass that through to see if it resolves your issue.
I tried to serialize a simple object inside the PCL it just returns a "{}" string. However, it does not throw any exceptions.
var test = new
{
Email = email,
Password = password,
Username = username
};
var testJson = JsonConvert.SerializeObject(test);
When I inspect the JsonConvertobject inside the VS debugger it says that the method SerializeObject is an unknown member. Furthermore, when I inspect the DeserializeMethod, it says:
Could not resolve type: global::Newtonsoft.Json.JsonConvert.DeserializeObject<DefaultResponse>
Both methods are displayed as variables inside the debugger.
import Vapor
import VaporMySQL
let mysql = try VaporMySQL.Provider(host: "localhost", user: "username", password: "secret", database: "coffeeLedger")
What is the difference between
let drop = Droplet(preparations: [CoffeeLedger.self], providers: [VaporMySQL.Provider.self])
and....
let drop = Droplet(preparations: [CoffeeLedger.self], providers: [mysql])
I get a Cannot convert value of type 'Provider' to expected element type 'Provider.Type' error
providers was renamed to initializedProviders in Vapor 0.16 to make room for ConfigInitializable provider support.
Basically, now you can just pass the Type of the provider and it will attempt to initialize from the configuration files in the Config/ folder.
This style of initialization helps remove magic numbers and strings from the source code, like the host and password.
If you want to keep initializing the provider normally, just use initializedProvider:
I cannot figure out how to pass a redirect url to accomplish OAuth2 authorization. Google REST API indicates that redirect_url parameters can be passed but this .Net API does not seem to have a feature to pass redirect url
Dim Coll As New List(Of String)
Coll.Add(CalendarService.Scope.Calendar)
Coll.Add(Google.Apis.Tasks.v1.TasksService.Scope.Tasks)
Dim credential As UserCredential = GoogleWebAuthorizationBroker.AuthorizeAsync(New ClientSecrets() With { _
.ClientId = ClientCredentials.ClientID, _
.ClientSecret = ClientCredentials.ClientSecret _
}, Coll, "user", CancellationToken.None, New SavedDataStore(myStoredResponse)).Result
Dim CalService = New CalendarService(New BaseClientService.Initializer() With { _
.HttpClientInitializer = credential, _
.ApplicationName = "myApp"})
A browser instance is launched when this code is executed but the return_url parameter in that request is always to to some random url (e.g., http://localhost:<random port number>/Authorize. Don't know where is this value coming from. In the API console, I have set http://localhost:4444/Home/Index. Since there is no match, authentication throws Error: redirect_uri_mismatch
The above code results into this request url
https://accounts.google.com/o/oauth2/auth?access_type=offline&response_type=code&client_id=589627125301.apps.googleusercontent.com&redirect_uri=http://localhost:44933/authorize/&scope=https://www.googleapis.com/auth/calendar https://www.googleapis.com/auth/tasks
In summary the question is, where is this http://localhost:44933/authorize/ coming from?
Any pointers as to how to set this redirect_uri parameter in the code?
Try adding a .CallbackURL property. Google API usually looks for one.