API3
dan1 at August 6th, 2018 04:41 — #1
Hi all,
I need a bit of help as I'm not a very experienced programmer. I'm struggling to log in using the Java API client. I haven't found a detailed documentation so I used the example from the Readme file on GitHub. Here's my code (I replaced my real username and password with asterisks for obvious reasons):
//Credentials
String username = "*********";
String pass = "******************************************************";
// Login
User loggedInUser = User.login(username, pass);
System.out.println(loggedInUser.getFirstName());
The code above returns a 401 response and an AuthenticationException:
INFO: Message: Unauthorized
Aug 06, 2018 8:48:32 AM com.onepagecrm.net.request.Request getResponse
INFO: Body: {"status":401,"message":"Invalid request data","error_name":"invalid_request_data","error_message":"Invalid login and/or password","errors":{}}
Aug 06, 2018 8:48:32 AM com.onepagecrm.net.request.Request getResponse
INFO: ****************************************
Exception in thread "main" com.onepagecrm.exceptions.AuthenticationException: Invalid request data
I've got my credentials from the API page ('Configuration' tab) in One Page (under 'APPS', top right corner). What am I doing wrong?
vladimir at August 6th, 2018 11:12 — #2
Hi Daniel!
You may have received Unauthorized response during login in the following cases:
1. You have provided invalid (or empty) credentials or deleted the user you were trying to log in. Please try to login with provided credentials in browser to check you're able to login
2. You haven't activated your account. When you create an account you receive an email with the link you should click in order to activate your account. So please make sure you've activated your account.
I hope that helps. Please feel free to ask your questions if you still have any.
P.S. Normally you should use the credentials with which you registered in OnePageCRM or the credentials of the users that you could have created in the users page (see Gear menu (top right corner) > Users and Billing). Please make sure you've set the passwords for newly created users.
All the best,
Vladimir
dan1 at August 6th, 2018 11:41 — #3
Hi Vladimir,
Sorted, thanks!
Best wishes,
Dan
Powered by Discourse, best viewed with JavaScript enabled