Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Franklin Ayran
Courses Plus Student 328 Pointslogin activity for a university app
What`s the best method for logging in on a university website using an Android app? It must act like a browser that can store session cookies.
Franklin Ayran
Courses Plus Student 328 PointsYes. I planned to first try scraping data off the website, since the university's office of management information systems doesn't want to give me any "special access", as they say.
James Barnett
39,199 PointsAnd very fragile any changes to their site will break your app, that's generally considered a terrible idea.
agreatdaytocode
24,757 PointsHi Franklin, try Androids WebView framework it maybe of some assistance. Draw back to doing this is that you will have little control over how things look. I hope the universities site is dynamic. http://developer.android.com/guide/webapps/index.html
Franklin Ayran
Courses Plus Student 328 PointsReally... I don't quite yet get the complexity of this. I am new to Java Android development and I don't know much about performing network operations. The first step is to display the logged in user after the log-in screen. I thought of parsing the content and reading the code that contains the name, the site is written in JavaScript. And for further improvements, can I still possibly catch the content of the site and use it for another activities? The university site that I am trying to access is https://aisis.ateneo.edu
Franklin Ayran
Courses Plus Student 328 PointsI think the site is dynamic, since it is our student information systems site. I am not really sure since I am a beginner programmer. Our university site is https://aisis.ateneo.edu
Franklin Ayran
Courses Plus Student 328 PointsJames Barnett and Jessica Sideways, how will I explain to the office of management information systems that I should have a special route/protocol for my Android application?
I appreciate your responses. :)
Ben Jakuben
Treehouse TeacherJames was mostly, but not totally right when he said scraping is a terrible idea. :) It depends one what you're doing and who you're doing it for. The risk is that any small change to the site can break your app. But if you're making something for yourself either as a learning experience or to try something out, then it can be a useful first approach. You just need to know that it can very quickly become much more of a pain than you had planned, so you need to be ready to abandon it quickly.
James Barnett
39,199 Points> But if you're making something for yourself either as a learning experience or to try something out, then it can be a useful first approach.
I concur, I was assumed (perhaps wrongly) that the use case here was to create an app for release.
Ben Jakuben
Treehouse TeacherI remember scraping Dilbert comics for an assignment in college! :-D
James Barnett
39,199 PointsBen Jakuben - That's a pretty awesome use case
5 Answers
agreatdaytocode
24,757 PointsWith (Xcode) you can create a simple UIWebview and point that to a url. It's very simple to do. Basically it's opening up safari inside the app. This allows the users to connect to the site via the app rather then opening up the browser it self. I "Think" you can do the same in Android. I took a look at the login page. It's not very mobile friendly.
Franklin Ayran
Courses Plus Student 328 PointsI will try out your suggestions and come back to this thread. If you have more suggestions, keep it coming. :) Thanks for the replies, will update you all soon if I will ever have a progress.
agreatdaytocode
24,757 PointsSounds good.
Ben Jakuben
Treehouse TeacherI put some code in a Gist that might help you, though I have no idea if it will work for your university site: https://gist.github.com/bendog24/7451769
The basic idea is that the login page you linked to sends the username and password to some URL to authenticate the user. You either need access to that login system or to figure out how to go up against it. You want to be very careful about trying to login to somebody's system, though. You want to have permission and make sure that no sensitive data is being transferred insecurely or captured.
That said, doing something like this can be a great learning experience.
James Barnett
39,199 Points> You want to have permission and make sure that no sensitive data is being transferred insecurely
You definitely need to get permission from the Office of Management Information Systems at https://aisis.ateneo.edu before starting on this.
Franklin Ayran
Courses Plus Student 328 PointsThank you, Ben Jakuben. Actually, James Barnett is right. After a few months, early next year, I must deploy the first version of this university app. To put this into perspective, this is for my thesis for Applied Computer Systems degree. I kind of think I made a wrong decision to chose this type of project when I can just go to traditional stuffs. My course is kind of a crash course Computer Engineering/Computer Science, because it is only for a year. I graduated BS Chemistry last semester. The reason that I signed up for the course is because my thesis adviser is not very familiar with Android application development so I am still finding a tutor right now, and I enjoy watching Ben's tutorials. I already talked to the Office of Management Information Systems (OMIS) last September. With just a little background on Android, I thought I could do the app without the special route protocol since I am just scraping off data, temporarily storing, then further manipulate the scraped data. And now here I am stuck with the first part, logging in, kind of frustrating actually. Maybe I should talk to the OMIS again soon, but I don't know exactly what to tell. Sorry for getting too personal.
Ben Jakuben
Treehouse TeacherWe're just glad you are discussing it here in the forum! Hopefully we are helping you find a path. It sounds like as an official project you'll have better luck getting access. Perhaps it's just finding the right person to talk to, which can be such a pain in and of itself.
Don't get too discouraged--handling authentication is one of the most important and hardest things you'll do as a developer. You HAVE to get it right. :) I'm not convinced you need any special protocol but rather just need an okay to authenticate against their system and a little information about how it is currently setup.
Franklin Ayran
Courses Plus Student 328 PointsBen, what are the information about the setup of the system that I need to know about? So when I consult with the OMIS again, it would be clear. They are also concern about the safety of the data being transferred. And quite frankly, I do not yet clearly understand how to do this. Thank you all for your help and suggestions. I'm happy to be here at Treehouse. :)
Ben Jakuben
Treehouse TeacherWell, I guess you need to know which kinds of authentication methods are available. I'm not much of a security expert myself--I always worked with our security team on this type of stuff in my previous job. If they accept Basic authentication then you should be able to pass the username and password in the request like the Gist I posted earlier. If they have a more formal protocol where you need to submit to a specific URL then you'll need to know the details about that.
I guess you want to start with the following questions:
- Is Basic authentication supported (i.e. passing the username and password in the URL as specified in the link earlier)? This would go hand in hand with an SSL connection (https)
- Is logging in exposed as any kind of web service?
If it's only available on their login page, you would need to talk with somebody familiar with how their login page works to explore options from there.
Hope it helps - the hardest part is figuring out what to do! Once you narrow down the technical details then you just need to implement it, and there is so much more help here and on the web for that part. :)
Véronique Bellamy
20,810 PointsVéronique Bellamy
20,810 PointsDepends. Can you get the University to let you code a special route/protocol that the app uses? Perhaps an API service that responds to queries from the phone app? If you're just scraping data off the website, that's a very inefficient way to go about it.