Microsoft Graph on android, responds 404 when retrieving file - java

On microsoft graph explorer i am able to retrieve the excel file easily but when trying on the "active-directory-android-native-v2-master" sample code, it returns 404.
On the the other hand, next line works and retrieves my information correctly
final static String MSGRAPH_URL = "https://graph.microsoft.com/v1.0/me";
I added all required permissions, got the client ID, run all the sample instructions, read the documentation + stack over flow.
I thought it might be because the link was not coded correctly so i modified the callGraphAPI() method to include:
Uri.Builder builder = new Uri.Builder();
builder.
scheme("https").
authority("graph.microsoft.com").
appendPath("v1.0").
appendPath("drives").
appendPath(MY_DRIVE).
appendPath("items").
appendPath(FILE_ID).
appendPath("workbook");
String url = builder.build().toString();
JsonObjectRequest request = new JsonObjectRequest(Request.Method.GET,url/*MSGRAPH_URL*/,
parameters,new Response.Listener<JSONObject>() {
#Override
public void onResponse(JSONObject response) {
but still the same response.
I came across the next stack overflow answer
404 file not found error when using microsoft graph api
And thought it might be the answer but then seen the question was old and another answer mentioned it is not longer correct.
appreciate any help.

It seems i was not aware using sample code for the V2 (active-directory-android-native-v2-master) while the graph explorer (which was working) used V1.
There is a great "getting started" tutorial for the V1 sample code (active-directory-android-master) here:
https://learn.microsoft.com/en-us/azure/active-directory/develop/quickstart-v1-android
Sample code seems quite the same only for V1.
When using the tutorial, i needed to find the required permissions for the command i was trying to use, in addition to the one mentioned at the tutorial.
I used the next link to get the permissions for the items:
https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/shares_get
I also added the permissions mentioned at the Graph Exlorer since as noted, the command i was trying to use worked there.
Since the permissions at the Azure site was not written the same (e.g. Files.Read is written as "Read user files") i used the next link to translate:
https://developer.microsoft.com/en-us/graph/docs/concepts/permissions_reference
Luckily i did not need to use any admin permissions, which would have complicated the registration to the app
Hopes this helps any struggled newbie like me :)
If anything from what i wrote not correct or you think i should add something, please let me know at the comments below and i will try to update
BTW - i used the Graph Exlorer to detect the files & Drive ID items i needed

Related

How to access to my album images on Imgur as json format?

I'm a newbie and in progress learning to code. Currently, I'm learning to chap Retrofit & API but have meet a problem that don't have on Google,I researched 2 days ago but cannot :(
This is my all images that i uploaded in 1 album: https://imgur.com/gallery/3fEbSEz
This is all informations related to authorization that i just registered (i think so, i followed the API docs imgur):
Client Name Client ID Client Secret
Get Images Imgur e17abdfa6dd2f71 85411f4e553fd0a5aab2740ea48abe296c8370bf
Through this link: https://api.imgur.com/models/gallery_album , I tried copy paste and replace content in {} by 3fEbSEz.
Example: https://api.imgur.com/3/gallery/album/3fEbSEz/images but as you can see, it cann't access into my album and display as json file format.
I wanna see the result like this: https://jsonplaceholder.typicode.com/photos . Yupp, like this, but ... hmm, i tried many times :((
So who can help me for this case, thanks so much for all helping!!!
This is error be returned when i tried manual link

How to add Cards to microsoft teams bot using Bot Framework SDK for Java?

I'm using the Java botbuilder to build a microsoft teams bot. I want to add Cards to my bot (e.g. to embed links, quick replies, and images).
In the above link it says: suggested actions are not supported in Microsoft Teams: if you want buttons to appear on a Teams bot message, use a card.
However, I can find no documentation on how to add a 'card' to the Activity schema.
I tried:
1. Using suggested actions
I tried adding my List<CardAction> to the SuggestedActions
field in Activity but they were not rendered by microsoft teams
(as expected, the documentation says this is not supported).
2. Using Attachments
I suspect it could be done using attachments, but can only find
documentation for the C#/JS versions (e.g.
https://learn.microsoft.com/en-us/azure/bot-service/nodejs/bot-builder-nodejs-send-rich-cards?view=azure-bot-service-3.0).
So I want to know how to add 'a card' to Activity schema so it can be rendered by my bot.
The BotFramework Java SDK is still in preview, so there isn't a lot of documentation I can point you towards. However, here is an example of adding a HeroCard to a reply.
Activity reply = new Activity()
.withType(ActivityTypes.MESSAGE)
.withRecipient(activity.from())
.withFrom(activity.recipient())
.withAttachments(Arrays.asList(
new Attachment()
.withContentType("application/vnd.microsoft.card.hero")
.withContent(new HeroCard()
.withTitle("Hero Card")
.withSubtitle("BotFramework")
.withButtons(Arrays.asList(new CardAction()
.withValue("https://learn.microsoft.com/en-us/azure/bot-service/")
.withTitle("Get started")
.withType(ActionTypes.OPEN_URL)
))
.withImages(Collections.singletonList(new CardImage()
.withUrl("https://sec.ch9.ms/ch9/7ff5/e07cfef0-aa3b-40bb-9baa-7c9ef8ff7ff5/buildreactionbotframework_960.jpg"))))
));
You can also take a look at the SDK Attachment Tests for more examples.
Hope this helps!

How to view a public Google Calendar via an Android Application

I must've gone through ever Stack Overflow question based on the Google Calendar so far with no luck what so ever. I've been trying this for hours now and got little to no results at all.
I'm a pretty new programmer with Java and Android, with quite little experience out of the field as it is. Basically the main problem I am having is with viewing another user's Google Calendar which is set to public.
At the moment, from the Google tutorials and other sites I've managed to get the calendar showing, which is pretty simple enough. It'll just load up and show the current user's calendar. Which can literally be done with (with a simple button in the layout).
public void onClick(View view) {
// A date-time specified in milliseconds since the epoch.
long startMillis = System.currentTimeMillis();
Uri.Builder builder = CalendarContract.CONTENT_URI.buildUpon();
builder.appendPath("time");
ContentUris.appendId(builder, startMillis);
Intent intent = new Intent(Intent.ACTION_VIEW).setData(builder.build());
startActivity(intent);
}
Obviously this doesn't pass in any user data for the public account or anything, I've been reading through the Calendar Provider Developer guides within the Google tutorials. I've tried to set up the account details thing, but it just never works. I've tried to do it as a Sync Adapter, but honestly I just know I'm not doing it right. I don't know if I really even need to use a Sync Adapter as all I want to do is literally see the events, not modify anything or update anything.
I am using API 14+ and want to user the Calendar Provider etc. It looks simple enough but I've been bashing my head against this for a few days and put a lot of hours into it and seemingly nothing I do works. At least I've got some sort of calendar opening but it's not what I want.
Is it all just down to the sync adapter? If so how will I be able to call a calendar? Another question similar had
private static Uri buildCalUri() {
return CalendarContract.Calendars.CONTENT_URI
.buildUpon()
.appendQueryParameter(CalendarContract.CALLER_IS_SYNCADAPTER, "true")
.appendQueryParameter(Calendars.ACCOUNT_NAME, ACCOUNT_NAME)
.appendQueryParameter(Calendars.ACCOUNT_TYPE, CalendarContract.ACCOUNT_TYPE_LOCAL)
.build();
}
I'm hoping this is something similar to what I need but I'm very unsure. In the developer tutorial ACCOUNT_TYPE_LOCAL was important if the account wasn't on the device
Any help will be greatly appreciated!
If you are looking to integrate the public Google Calendar (www.google.com/calendar) with your Android Application, you have to use the Google Calendar API.
The easiest method would be download the Google Calendar Client Library from here and then use the API Reference here. In the Client Library Page, you want to download "Google APIs Client Library for Java (rc)" package to integrate into your Android App.
You will first need to go to API Console to create an App with Calendar API Access .
If you do not want to use the native library, you can even do it using REST API (use HTTP GET & POST Commands), example App here
Hope this helps.
For anybody that has followed the Android Developer API example, but still can't find how to add a public calendar. Try out
CalendarListEntry gracieCal = new CalendarListEntry();
gracieCal.setId("your-public-calendar-id");
mService.calendarList().insert(gracieCal);
Events events = mService.events().list(gracieCal.getId())
.setMaxResults(10)
.setTimeMin(new DateTime(System.currentTimeMillis()))
.setOrderBy("startTime")
.setSingleEvents(true)
.execute();
List<Event> items = events.getItems();
'mService' is the com.google.api.services.calendar.Calendar instance that you should have already created. (see the api tutorials mentioned by the other answer)
'your-public-calendar-id' can be found in the settings for your public google calendar.

POST Password and Email data to Google Sign-in

All- I have the code:
doc = Jsoup.connect("https://play.google.com/apps/publish/Home?dev_acc=00758402038897917238")
.data("input#Email", "email#gmail.com")
.data("input#Passwd", "123abcABC123" )
.post();
I got his from here: SO question but could not figure out what is wrong. I am getting the sign in page instead of the page displaying all my published apps. I belive the problem might lie in the input#Email and input#Passwd but I am not sure. I don't quite understand what that is supposed to refer to. So my question: how can I login to my developer console using code similar to the one above and what is supposed to go where input#Email and input#Passwd are?
In post you have to use names, not css selectors:
doc = Jsoup.connect("https://play.google.com/apps/publish/Home?dev_acc=00758402038897917238")
.data("Email", "email#gmail.com")
.data("Passwd", "123abcABC123" )
.post();

Google Calendar

I'm developing one web application project using java for education industry.In this Admin have all rights to access the google services of other users like A,B,C..... for this is use OAuth.Then i tried Admin want to share user A's calendar to user B using OAuth.But i got stuck in this step. Is it possible Plz Help me
Thanks
Regards
Sharun
I believe you want to use Access Control Lists (ACLs), see the docs. The Java example code at this URL for the task you mention is pretty simple:
AclEntry entry = new AclEntry();
entry.setScope(new AclScope(AclScope.Type.USER, "jdoe#gmail.com"));
entry.setRole(CalendarAclRole.READ);
URL aclUrl =
new URL("http://www.google.com/calendar/feeds/jo#gmail.com/acl/full");
AclEntry insertedEntry = service.insert(aclUrl, entry);
and what it does is, and I quote:
This code allows jdoe#gmail.com to
have read-only access to
jo#gmail.com's calendar.
There's more where this came from (e.g., upgrading a user's role in an ACL above the read-only access granted in this example), and I think it's a good idea to read the whole page.

Categories