No authentication challenges found - android

I tried to use
try {
new TwitterFactory(new ConfigurationBuilder()
.setOAuthConsumerKey(TWITTER_KEY)
.setOAuthConsumerSecret(TWITTER_SECRET)
.setOAuthAccessToken(TWITTER_TOKEN)
.setOAuthAccessTokenSecret(TWITTER_TOKEN_SECRET)
.build()).getInstance().updateStatus("HELLO WORLD!");
} catch (TwitterException e) {
e.printStackTrace();
}
But as soon as I run it, it gives me this error:
this might be a possible answer: In order to get access acquire AccessToken using xAuth, you must apply by sending an email to api#twitter.com — all other applications will receive an HTTP 401 error. from here but his answer is not complete (does not have steps to follow)
How to fix this? Thanks!

Related

How does Keycloak with Android work using SAML protocol?

I've successfully created a demo in Android using keycloak openid-connect protocol configuration for SSO. Now I want to do with SAML protocol.
Details I used in openid-connect:
client_id
username
password
grant_type
client_secret
Now, when I changed from openid-connect to SAML inside keycloak dashboard, so client-secreted option got invisible.
So, in android I removed that variable, and also changed in URL from openid-connect to SAML. But getting error that Page not found
I seen lot of example, searched and imported github project as well, but wither I'll get demo with openid-connect or I'll get demo without using keyclaok.
I don't understand what else is required.
BTW, I followed this example for openid-connect and it is working as well: https://github.com/thomasdarimont/android-openid-connect/tree/feature/keycloak-oidc-demo
I'll share a bit code:
protected Boolean doInBackground(String... args) {
String authToken = args[0];
IdTokenResponse response;
showLog("Requesting ID token.");
try {
response = OIDCUtils.requestTokens(Config.tokenServerUrl,
Config.redirectUrl,
Config.clientId,
authToken);
} catch (IOException e) {
Log.e(TAG, "Could not get response.");
e.printStackTrace();
return false;
}
if (isNewAccount) {
createAccount(response);
} else {
setTokens(response);
}
return true;
}
Have a look, and there are really less examples on this things. Don't know why!
SAML is primarily for Browser Based Authentication (including Auth-Requests, Redirects, ...). So that's not really suitable for Android apps.
Do you have a good reason to use SAML and not stick to your (already working) OIDC solution?

Update Status in Twitter via twitter4j Library - 401 Authontication Credentials... error

Hi I am trying to implement "status update" via twitter4j library.
However it am always getting the same error:
401:Authentication credentials (https://dev.twitter.com/pages/auth)
were missing or incorrect.
Ensure that you have set valid consumer key/secret, access token/secret, and the system clock in in sync.
TwitterException{exceptionCode=[6b80c41c-1bd1da85], statusCode=401,
retryAfter=-1, rateLimitStatus=null,
featureSpecificRateLimitStatus=null, version=2.2.5-SNAPSHOT(build:
5f9c44cd0e0c1972f8d17653a226b9b6a3392ac2)}
...
Below you can find the code piece:
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(true)
.setOAuthConsumerKey(cons_key)
.setOAuthConsumerSecret(cons_secret)
.setOAuthAccessToken(acc_token)
.setOAuthAccessTokenSecret(acc_secret);
TwitterFactory tf = new TwitterFactory(cb.build());
Twitter twitter = tf.getInstance();
twitter4j.Status status;
try {
status = twitter.updateStatus(params[0]);
if (status.getId() == 0) {
System.out.println("Error occured while posting tweets to twitter");
}
} catch (TwitterException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
I am pretty sure about I have the valid consumer/access tokens/secrets.
I don't know how to sync the system clock.
Do you have an idea what is the actual problem behind this error? I couldn't find any useful answer on internet.
Any help would be appreciated..
Thanks in advance!
You can try few things -
Regenerate the authentication keys for your registered app by logging in to https://apps.twitter.com.
Also ensure your registered application has Read/Write access to be able to post an status update.
I am not sure about clock sync on android, but for linux/Windows you can check
which NTP server to point your system to.
Also use latest version of twitter4j.

how can i send all exception from try catch in my app android to server or email?

I need send all exception in my app to server or email, not crash. How can i do that?
try{
}catch(Exception e){
// here send e.getMessage() to server or email
}
Someone can help me?
Crashlytisc is the answer to you question. Your fatal exceptions will be logged to Crashlytics server implicitly while to log non-fatal exceptions you have to do it explicitly, like following;
try{
} catch(Exception e){
// Crashlytics.log(PRIORITY, TAG, MESSAGE);
Crashlytics.log(android.util.Log.ERROR, "TAG","Message");
}
That's what Exception Handling(your try catch is there for),Your App crashes when there is some Exception.Catch it in your try block and handle it in catch....You can write the java code of sending an email in the catch block.The exception generated will be passed as a an argument to the catch....
I am considering that you are not talking of NullPointerException or the other common UI exceptions .
See this for learning about Sending Email

Android: Fatal Exceptions in GoogleAuthUtil

I am working on an Android app which uses Google for authentication. Our code for fetching a token to verify a user's identity is as follows, following the "auth" sample Android project's GetNameInForeground.java:
/**
* Get a authentication token if one is not available. If the error is not recoverable then
* it displays the error message on parent activity right away.
*/
#Override
protected String fetchToken() throws IOException {
try {
return GoogleAuthUtil.getToken(mActivity, mEmail, mScope);
} catch (GooglePlayServicesAvailabilityException playEx) {
// GooglePlayServices.apk is either old, disabled, or not present.
mActivity.showErrorDialog(playEx.getConnectionStatusCode());
} catch (UserRecoverableAuthException userRecoverableException) {
// Unable to authenticate, but the user can fix this.
// Forward the user to the appropriate activity.
onError("Authorization problem with Google account", userRecoverableException);
//mActivity.startActivityForResult(userRecoverableException.getIntent(), mRequestCode);
} catch (GoogleAuthException fatalException) {
onError("Unrecoverable error " + fatalException.getMessage(), fatalException);
}
return null;
}
When logging in, we regularly receive the error "Unrecoverable error unknown." This suggests that we are getting fatalExceptions from calling GoogleAuthUtil.getToken, but we can't tell why. http://developer.android.com/reference/com/google/android/gms/auth/GoogleAuthUtil.html doesn't give much information regarding error messages.
I saw this error when I accidentally tested a binary that was signed with the Temporary Eclipse Generated credentials. I believe you need to sign the binaries with the same keys used to generate the server client-id in Google Play Console . If using Eclipse, do a signed export of the app and install.

Smack, Getting Error in creating new MultiChat

I am using asmack for creating a chat app.
For creating a MultiUserChat i am using following code.
muc= new MultiUserChat(HomeActivity.connection, "chatRoom#conference.live-images.com");
try
{
muc.create(HomeActivity.connection.getUser());
muc.sendConfigurationForm(new Form(Form.TYPE_SUBMIT));
muc.join("kam");
}
catch (XMPPException e)
{
e.printStackTrace();
}
But i an getting the error.
Class CastException. & if i remove the Confrence from new MUC() then I get
Server Not Responsing Error.
Where i am wrong? Do i have to use some Patch.
it would be better to send more details like the stack trace.
Make sure you follow the code example here:
Multi User Chat

Categories

Resources