OK, I found this:
http://code.google.com/apis/youtube/2.0/developers_guide_java.html#ClientLogin_for_Installed_Applications
Should have read the docs more carefully :)
It suggests supplying the password like this:
YouTubeService service = new YouTubeService(clientID, developer_key);
service.setUserCredentials("[email protected]", "password");
My question now is how to store "password" securely in Android. The
first time the password is needed, I guess I can just do a popup with
email and password field, but it would be nice to store the password
in Settings. Can I do this securely? Would I need to hash it?
Thanks!
Anna
On Feb 27, 3:07 pm, Anna PS <[email protected]> wrote:
> I'm writing an Android app that, among other things, uses the GData
> libraries to upload videos shot with the camera to Youtube (code
> below). However, I'm a bit confused about how to authenticate my
> users.
>
> Can I simply assume that they are already signed in to Youtube, since
> they're using Android? Or do I need to ask them to authenticate? In
> which case, should I use ClientLogin?
>
> There seems to be little example code on how to use ClientLogin in
> Android, and since it's using people's Google account passwords, it
> obviously needs to be secure. I'm a bit concerned at the prospect of
> writing my own authentication code without much guidance, and at the
> extra step required from users.
>
> It seems odd that I have to ask people to authenticate for a Google
> service, given that they are using Google phones and the inbuilt
> Google apps don't require external authentication. Why is this? It
> seems to put my app at a disadvantage to Google's own apps.
>
> -----------------------------
>
> Here's the code that I have, below:
>
> private void testGdata() {
>
> YouTubeService service = new YouTubeService(clientId,
> developerKey);
>
> VideoEntry newEntry = new VideoEntry();
>
> YouTubeMediaGroup mg = newEntry.getOrCreateMediaGroup();
> mg.setTitle(new MediaTitle());
> mg.getTitle().setPlainTextContent("Custom title here");
> mg.addCategory(new
> MediaCategory(YouTubeNamespace.CATEGORY_SCHEME,
> "Politics"));
> mg.setKeywords(new MediaKeywords());
> mg.getKeywords().addKeyword("myImportantKeyword");
> mg.setDescription(new MediaDescription());
> mg.getDescription().setPlainTextContent("Custom description
> here");
> mg.setPrivate(false);
> mg.addCategory(new
> MediaCategory(YouTubeNamespace.DEVELOPER_TAG_SCHEME, "mydevtag"));
> mg.addCategory(new
> MediaCategory(YouTubeNamespace.DEVELOPER_TAG_SCHEME,
> "anotherdevtag"));
>
> newEntry.setGeoCoordinates(new GeoRssWhere(37.0,-122.0));
> // alternatively, one could specify just a descriptive string
> // newEntry.setLocation("Mountain View, CA");
>
> //MediaFileSource ms = new MediaFileSource(new
> File("file.mov"),
> "video/quicktime");
> MediaFileSource ms = new MediaFileSource(video, "video/3gpp");
> newEntry.setMediaSource(ms);
>
> String uploadUrl =
> "http://uploads.gdata.youtube.com/feeds/api/users/default/
> uploads";
>
> try {
> VideoEntry createdEntry = service.insert(new
> URL(uploadUrl),
> newEntry);
> } catch (MalformedURLException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> } catch (IOException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> } catch (ServiceException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
> }
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en