Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Oauth2 login failed
I tried to log in to life portal (7.1) via SDK on android.
I registreted a mobile app in portal's oath administration menu, created id and secret key.
When I try to log in like this:
at com.liferay.mobile.android.auth.oauth2.TokenRequester.parseResponse(TokenRequester.java:113)
at com.liferay.mobile.android.auth.oauth2.TokenRequester.access$300(TokenRequester.java:25)
at com.liferay.mobile.android.auth.oauth2.TokenRequester$1.onResponse(TokenRequester.java:99)
at com.squareup.okhttp.Call$AsyncCall.execute(Call.java:177)
at com.squareup.okhttp.internal.NamedRunnable.run(NamedRunnable.java:33)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
When I try to log in as guest, like this:
Why can't I log in with user / pwd?
Thanks for your help!
implementation 'com.liferay.mobile:liferay-android-sdk:7.1.3'
implementation 'com.liferay.mobile:liferay-android-oauth:1.3.0'
implementation 'com.liferay.mobile:liferay-mobile-sdk-services:1.0'I registreted a mobile app in portal's oath administration menu, created id and secret key.
When I try to log in like this:
OAuth2SignIn.signInWithUsernameAndPassword("<user_email>","<user_pwd>",new SessionImpl(SERVER),ID,SECRET,new ArrayList<string>(),new SessionCallback() {
@Override
public void onSuccess(Session newSession) {
session=SessionContext.createOAuth2Session(newSession);
LOG.info("LogIn success: " + session);
LOG.info("LogIn success: " + SessionContext.isLoggedIn());
loadUserData(callback);
}
@Override
public void onFailure(Exception e) {
e.printStackTrace();
logout();
}
});</string></user_pwd></user_email>The login always fail with com.liferay.mobile.android.exception.ServerException: at com.liferay.mobile.android.auth.oauth2.TokenRequester.parseResponse(TokenRequester.java:113)
at com.liferay.mobile.android.auth.oauth2.TokenRequester.access$300(TokenRequester.java:25)
at com.liferay.mobile.android.auth.oauth2.TokenRequester$1.onResponse(TokenRequester.java:99)
at com.squareup.okhttp.Call$AsyncCall.execute(Call.java:177)
at com.squareup.okhttp.internal.NamedRunnable.run(NamedRunnable.java:33)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
When I try to log in as guest, like this:
OAuth2SignIn.clientCredentialsSignIn(new SessionImpl(SERVER),ID,SECRET,new ArrayList<string>(),new SessionCallback() {
@Override
public void onSuccess(Session newSession) {
session=SessionContext.createOAuth2Session(newSession);
LOG.info("LogIn Guest success: " + session);
}
@Override
public void onFailure(Exception e) {
e.printStackTrace();
logout();
}
});</string>the login is successful.Why can't I log in with user / pwd?
Thanks for your help!
Hey!
Can you share your oauth2 configuration? From the server
Can you share your oauth2 configuration? From the server
I solved the problem. I use createBasicSession to authenticate user with email and pwd. I only use OAUTH2 credentials for guest users.