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.
Related
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!
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
I find a way to implement twitter login with github twitter4j but I want to implement it without using any third party library. With the twitter document, I am not able to understand what should I do for it. From where I can get oauth_nonce, oauth_timestamp & oauth_signature's value? Please suggest me a good way to implement twitter login in web.
Please suggest me a good way to implement twitter login in web.
The Twitter developer documentation says this:
"Most developers will not need to work with the details of OAuth, since Twitter Client Libraries already implement the protocol. It is strongly recommended to use one of these libraries. "
If you choose to ignore that advice, then the same page has links to other pages that explain OAuth, explain various ways to get tokens, and explain how to ad authentication details to your requests.
I am myself the developer of a ThirdParty library and I will definitely advise to use them. Twitter authentication has multiple problems to consider.
Anyway here is an answer for you.
// oauth_nonce
var oauth_nonce = new Random().Next(123400, 9999999).ToString(CultureInfo.InvariantCulture);
// oauth_timestamp
TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
var oauthTimestamp = Convert.ToInt64(ts.TotalSeconds).ToString(CultureInfo.InvariantCulture);
Signature is a bit more complicated. You need to extract all the params of your query. Order them by name, Append all of them into a string separated with '&' (lets call it URL_PARAMETERS).
Then create a string as followed {HTTP_METHOD}&{BASE_URL}&{URL_PARAMETERS}
Now you simply have to compute the Hash of the previous value with the oauth_secret_key (from Twitter app).
And not you can simply do oauth_signature = Http.UrlEncode(Convert.ToBase64(<HASH>)).
Also don't forget
var oauth_signature_method = "HMAC-SHA1";
When I'm changing role programmatically then updated role is not taking place immediately until run clean up permissions from control panel.
Is there any way to call some APIs to do the same through program itself?
the method doing it is CleanUpPermissionsUtil.cleanUpAddToPagePermissions(ActionRequest)
but the problem that it is a internal utility and is not possible to call in a plugin. It execute in the PortalContext.
You can see the source of the class at the link and try to replicate the code maybe in your logic
https://github.com/liferay/liferay-portal/blob/6.2.x/portal-impl/src/com/liferay/portlet/admin/util/CleanUpPermissionsUtil.java
This is the way that you should use to reload permission from update role:
Role role = RoleLocalServiceUtil.getRole(companyId, RoleConstants.USER);
List<ResourcePermission> roleResourcePermissions = ResourcePermissionLocalServiceUtil.getRoleResourcePermissions(role.getRoleId());
for(ResourcePermission permission : roleResourcePermissions )
ResourcePermissionLocalServiceUtil.reassignPermissions(permission.getResourcePermissionId(),role.getRoleId());
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.