Verifying push authentication in Okta Java SDK - java

How can I get the answer user provides to the push notification through their phone using Java SDK? It requires transactionId in addition to other parameters used in verification of other factors as far as I understand. But where to set this?

https://github.com/okta/okta-sdk-java/issues/321
ExtensibleResource resource = client.instantiate(ExtensibleResource.class);
ExtensibleResource protocolNode = client.instantiate(ExtensibleResource.class);
protocolNode.put("type", "OAUTH");
resource.put("protocol", protocolNode);
ExtensibleResource result = client.http().get(pollUrl, ExtensibleResource.class);

Related

How to get aws cloudsearch domain's search endpoint using AWS Java sdk

hi I want to get search endpoint from cloudsearch domain using AWS Java sdk from offical documentation it is stated that we can use describeDomain method. but it not not mentioned how we use that method exactly anybody have done something similar or have any clue for this ?
You need to get the domain status and then get the search endpoint from the domain status.
AmazonCloudSearchClient csClient = new AmazonCloudSearchClient(new BasicAWSCredentials(accessKey, secretKey));
DescribeDomainsRequest describeDomainsRequest = new DescribeDomainsRequest();
describeDomainsRequest.setDomainNames(domainName);
DescribeDomainsResult describeDomainsResult = csClient.describeDomains(describeDomainsRequest);
DomainStatus domainStatus = describeDomainsResult.getDomainStatusList().get(0);
String searchEndpoint = domainStatus.getSearchService().getEndpoint();

What is the Java library to popup an AzureAD browser for user login user then and output a token?

I am developing a solution that needs an token to request a rest API. I want in the beginning of my code to popup a window to user and receive an answer with a token.
I am developing an intention at JetBrains MPS that demands permission from the user to do so. I read this on GitHub: https://github.com/AzureAD/azure-activedirectory-library-for-java/
The problem is that I need to input the username and password as a string, not through a Azure site.
I wish my code could look like this
azureADHelper foo = new azureADHelper()
string userType = "admin"
string companyWebName = "https://stackoverflow.com/"
foo.askUserIdentity(userType, companyWebName)
if (foo.permission == true){
string token = foo.getToken()
}
Azure Active Directory provides several libraries for different platform. For java "ADAL4J" library is used.
I hope the below code screenshot will help to address your issue:
You can check the below sample to configure azure ad in java.
https://github.com/Azure-Samples/active-directory-java-webapp-openidconnect

Authenticate with Cognito Federated Identities

I am having a hard time trying to figure out how to use Amazon Cognito in my web app (Java based). I want to have some kind of authentication hub (Amazon Cognito) to authenticate user with multiple Auth Providers - that's why I want to use Amazon Cognito! :)
Firstly, I set up User Pool (I have my UserPoolId: eu-central-1_xxxxxxxxxx) and created there one user. Next I created Identity Pool with IdentityPoolId (eu-central-1:yyyyyyyyyy). Then I authenticate with AWS JavaScript SDK to UserPool to get idToken and it working quite fine! I receive idToken from Cognito UserPool. Then I am sending this idToken to my backend app (Java based) and there I want to validate this idToken with IdentityPool. I added new Authentication Provider - Cognito with UserPoolId and newly created id of an App that I added in UserPool. I tried to follow with this tutorial:
https://aws.amazon.com/blogs/mobile/use-amazon-cognito-in-your-website-for-simple-aws-authentication/
But everytime I make
GetID
request I recevied Exception with
com.amazonaws.services.cognitoidentity.model.NotAuthorizedException: Token is not from a supported provider of this identity pool.
My Java code is below:
final AmazonCognitoIdentityClient identityClient = new AmazonCognitoIdentityClient(
new BasicAWSCredentials("accessKey", "secretKey"));
identityClient.setRegion(Region.getRegion(Regions.EU_CENTRAL_1));
GetIdRequest idRequest = new GetIdRequest();
idRequest.setAccountId("accountId");
idRequest.setIdentityPoolId(identityPoolId);
final String providerName = "cognito-idp.eu-central-1.amazonaws.com/eu-central-1_xxxxxxxx";
Map providerTokens = new HashMap();
providerTokens.put(providerName, idToken);
idRequest.setLogins(providerTokens);
GetIdResult idResp = identityClient.getId(idRequest);
Does anyone could help me with this task? Maybe I am doing something wrong?
Thanks,
Kamil :)
There are three pieces of data that need to match in this scenario:
Provider as configured in AWS.
Provider as put into the Logins map.
iss value (issuer) in the id token.
When I have seen this error, it has been because the value in the Logins map does not match the provider as configured in AWS.
For example, an unexpected port number or trailing slash can cause these not to match.
Beyond this, there are a couple of settings in AWS that need to line up.
Provider as configured in AWS
With a Cognito User Pool, Amazon configures this name for you, so it's non-configurable on the backend. The format of the providerName in your Java code looks good, but first I'd triple check the xxxxxxx part for a typo.
App Client settings
Then, make sure your App Client has Cognito enabled in your User Pool settings:
Federated Identities settings
Next, in your federated identities settings, verify that the user pool id and client id appear in the Cognito tab under "Authentication providers", and that they match your user pool and App Client.
JWT issuer
Finally, I would expect the error to be "Invalid login token. Issuer doesn't match providerName" if there was a problem with the iss value in the JWT. However, decoding the id token you get back and inspecting the contents (as suggested in another answer) is also good advice.
If all these pieces appear to be in place, and the error persists, please leave a comment. Happy Hacking!
When you created your user pool double check you have all the expected federated providers supported. If you use developer authenticated make sure you add that 'login....' domain as well.
Grab your/a token and look at it in jwt.io for clues as well.

PayPal how to set credentials programmatically in java sdk (express checkout)

I'm using PayPal Express Checkout to make reference payments. Right now, the sdk loads PayPal credentials (user id, password, signature) from a resource file (sdk_config.properties) - is there any way to set the credentials (user id, password, signature) from code?
I'm not familiar with their SDK but you should be able to just update the values of those constants or whatever types of variables they're using with your own dynamic values.
Alternatively, you might want to look into the Permissions API as it sounds like you're attempting to make calls on behalf of 3rd party users..??
We have made some good improvements to the PayPal Java SDK on integration steps. We are removing the need for sdk_config.properties file as they do not work as well, specially for multi-configuration settings.
Now, all you do is create an APIContext instance with clientId, clientSecret, and mode. You pass that context object for any API operation from there on.
Here is how the code would look like:
APIContext context = new APIContext(clientId, clientSecret, "sandbox");
Payment payment = new Payment();
// Fill in all the details.
payment.create(context);
Here is the wiki page explaining that: https://github.com/paypal/PayPal-Java-SDK/wiki/Making-First-Call

Linkedin api call using oauth in java

I am trying to fetch Linkedin company updates to my website. Followed the process https://developer.linkedin.com/documents/authentication and generated api key and secret key by registering.
According to the documentation I am able to generate the Authorization Code in Step a.
For Step b to generate Access Token I am using OAuth in java.
request = OAuthClientRequest.tokenLocation("https://www.linkedin.com/uas/oauth2/accessToken")
.setGrantType(GrantType.AUTHORIZATION_CODE)
.setCode("****")
.setRedirectURI("https://www.example.in")
.setClientId("*******")
.setClientSecret("******").buildBodyMessage();
OAuthClient oAuthClient = new OAuthClient(new URLConnectionClient());
GitHubTokenResponse oAuthResponse = oAuthClient.accessToken(request, GitHubTokenResponse.class);
String accessToken = oAuthResponse.getAccessToken();
String expiresIn = oAuthResponse.getExpiresIn();
But getting error
OAuthProblemException{description='Missing parameters: access_token', error='invalid_request', uri='null', state='null', scope='null'}
at org.apache.amber.oauth2.common.exception.OAuthProblemException.error(OAuthProblemException.java:57)
at org.apache.amber.oauth2.common.utils.OAuthUtils.handleOAuthProblemException(OAuthUtils.java:166)
at org.apache.amber.oauth2.common.utils.OAuthUtils.handleMissingParameters(OAuthUtils.java:184)
at org.apache.amber.oauth2.client.validator.OAuthClientValidator.validateRequiredParameters(OAuthClientValidator.java:90)
at org.apache.amber.oauth2.client.validator.OAuthClientValidator.validateParameters(OAuthClientValidator.java:53)
at org.apache.amber.oauth2.client.validator.OAuthClientValidator.validate(OAuthClientValidator.java:49)
at org.apache.amber.oauth2.client.response.OAuthClientResponse.validate(OAuthClientResponse.java:64)
at org.apache.amber.oauth2.client.response.OAuthClientResponse.init(OAuthClientResponse.java:59)
at org.apache.amber.oauth2.client.response.OAuthAccessTokenResponse.init(OAuthAccessTokenResponse.java:52)
at org.apache.amber.oauth2.client.response.OAuthClientResponseFactory.createCustomResponse(OAuthClientResponseFactory.java:60)
at org.apache.amber.oauth2.client.URLConnectionClient.execute(URLConnectionClient.java:105)
Please help to fix this. Thanks in advance for any help.
I spotted the issue.
Looks like there is a problem in the documentation.
Apologies.
Right call is
request = OAuthClientRequest.tokenLocation("https://www.linkedin.com/uas/oauth2/accessToken")
.setGrantType(ResponseType.CODE.toString())
.setCode("****")
.setRedirectURI("https://www.example.in")
.setClientId("*******")
.setClientSecret("******").buildBodyMessage();
Mind ResponseType.CODE.toString() rather than GrantType.AUTHORIZATION_CODE
I suggest you go through some of the linkedin developer docs here, and check out a java OAuth library rather than performing the signing process by hand. Then you can ask a specific question.

Categories

Resources