Google Calendar API - How to save/use StoredCredentials? - google-api

The task is to save the stored credential file contents to database.
I am using the Google Java client quickstart project to get calendar and events from google. I am also using the offline access flag and set it as true. In the startup code it uses this:
.setDataStoreFactory(new FileDataStoreFactory(new java.io.File(TOKENS_DIRECTORY_PATH)))
So instead of this FileDataStoreFactory can we use something else, so that I can write the contents to my database
Full code : https://developers.google.com/calendar/quickstart/java#step_3_set_up_the_sample
I wanted to understand if I can save this StoredCredential file contents to the database for each user, so that I can schedule this calendar sync.
Any help will be appreciated.

Related

Call Google Spreadsheet by bash

I would like to call my private google spreadsheet by bash/shell. I don't want to edit it or something, only read it and put the content on the stand-output...
Is it possible?
I found a way, where I can call published projects from Google Drive, but that doesn't fit, as I have confidential data in that spreadsheet!
Also I haven't find an easy to use API solution to do that one simple thing.
Thanks!
Yes it's possible.
Your script will need to do 3 things, each with curl:-
Use a saved Refresh Token to request an Access Token
Use the Access Token to fetch your spreadsheet's File resource (json)
Parse the json to extract the exportLinks object, and choose which format (eg. csv) you want to download
GET that exportLink

How to use the File API to store text data in the samsung TV?

How to use the File API to store text data in the samsung TV ?
And the data will "live" until the application uninstalled.
I implemented video api of samsung tv. When start my api, asking for user login account. But, I want to store user's login details. User don't need to enter every time login credentials. If once user logged in, and next time username and password should pre populated with details. I think file api is useful for me. But don't understand how to use it. Where to store file which is going to use or what should be extension? And how to access that file fileSystemObj.openCommonFile(curWidget.id + '/testFile.data', 'r');
what is this "curWidget.id" I mean how to use it for my app?
Please, guide me. Or if possible provide me an example.
curWidget.id is widget id of the app in the widgetlist.xml is written widget id.
I hope it is helpful for you
curWidget.id is identificator of installed widget, it is provided by smart hub. When you publish your app, it is generated by seller site.
Basic guideline about files: your app should create directory for its files. Recommened path is value of curWidget.id property.
Example available in Samsung documentation: http://samsungdforum.com/Guide/?FolderName=tec00111&FileName=index.html
var fileSystemObj = new FileSystem();
if (fileSystemObj.isValidCommonPath(curWidget.id) == 0){
fileSystemObj.createCommonDir(curWidget.id);
}
var jsFileObj = fileSystemObj.openCommonFile(curWidget.id + "/data.dat","w");
/* Some code */
fileSystemObj.closeCommonFile(jsFileObj);
Your files will stay and after app uninstallation. You will have to remove them yourself. This is also covered in guide.

Download build drop from hosted Team Foundation Service

Using the hosted Team Foundation Service at tfs.visualstudio.com, one has the option in a Build Definition to "Copy build output to the server" which creates a zip of the drop folder that can be downloaded over https via team web access. I really need to download this drop automatically, so I can chain input to the next stage in my build pipeline.
Unfortunately, the drop URL is not obvious, but can be created using the TfsDropDownloader.
TL;DR - I can't get the TfsDropDownloader to work, I'm hoping someone else has used this tool or a similar method to succesfully download a drop from https://tfs.visualstudio.com
Using the command line TfsDropDownloader.exe I can do this:
TfsDropDownloader.exe /c:"https://MYPROJECTNAME.visualstudio.com/DefaultCollection" /t:"ProjectName" /b:"BuildDefinitionName" /u:username /p:password
...and get an empty zip file with the correct build label name of the last successful build e.g. BuildDefinitionName_20130611.1.zip
Running the source code in the debugger, this is because the URL that is generated for downloading:
https://tflonline.visualstudio.com/DefaultCollection/_apis/resources/containers/804/drop/BuildDefinitionName_20130611.1.zip
..returns a content type of application/json, which is unsupported. This exception is swallowed by the application, but not before the empty zip file is created.
Is it possible the REST API on Team Foundation Service has changed in some way so the generated URL is no longer correct?
Note that I am using the "alternate credentials" defined on my Team Foundation Service account (i.e. not my live ID) - using anything else gets me TF30063: not authorized.
I got it working by using alternate credentials, but I also had to access the REST API via a different path.
The current TfsDropDownloader builds a URL that looks like this:
https://project.visualstudio.com/DefaultCollection/_apis/resources/containers/804/drop/BuildDefinitionName_20130611.1.zip
This returns empty JSON whenever I try to use it. I'm definitely authenticated, because if I tweak the URL to:
https://project.visualstudio.com/DefaultCollection/_apis/resources/containers/804/drop
I get a nice JSON listing of every single file in the drop, but no zip.
From spying on the SSL traffic to https://tfs.visualstudio.com with Fiddler I saw that clicking the "Download drop as zip" link I can see that there is another endpoint at:
https://project.visualstudio.com/DefaultCollection/ProjectName/_api/_build/ItemContent?buildUri=vstfs%3a%2f%2f%2fBuild%2fBuild%2f639&path=%2Fdrop
...which does give you a zip. The "vstfs%3a%2f%2f%2fBuild%2fBuild%2f639" portion is the URL encoded BuildUri.
So I've changed my version of GetServerPath in the TfsDropDownloader source to do this:
private static string GetServerPath(TfsConnection collection, IBuildDetail buildDetail)
{
var downloadPath = string.Format("{0}{1}/_api/_build/ItemContent?buildUri={2}&path=%2Fdrop",
collection.Uri,
HttpUtility.UrlPathEncode(buildDetail.TeamProject),
HttpUtility.UrlEncode(buildDetail.Uri.ToString()));
return downloadPath;
}
This works for me for the time being. Hopefully this helps someone else with the same problem!

DocsList findFolder() issue

This is a google spreadsheet script question.
I have a GUI setup in order to search for "SouthWest" and then find a "test" sheet. This is the code I am using.
var file = DocsList.getFolder("SouthWest").find("test");
This works just fine when I run it under my account (as I have this folder and file setup correctly) but when another user is logged into google docs it will attempt to search for this folder/file under the new user instead of the owner of the document. Is there a way to have it just search the DocsList of the owner of the spreadsheet that is currently open? The error that I get under the new user is "Error encountered: Cannot find folder SouthWest." Thanks.
If you always want to access the same file, you can use the getFileById method and address it directly instead of searching every time:
https://developers.google.com/apps-script/class_docslist#getFileById
Of course, you should make sure that all users are allowed to access that file.

How entity edit URL from within plug-in in MS Dynamics CRM 4.0

I would like to have a workflow create a task, then email the assigned user that they have a new task and include a link to the newly created task in the body of the email. I have client side code that will correctly create the edit URL, using the entities GUID and stores it in a custom attribute. However, when the task is created from within a workflow, the client script isn't run.
So, I think a plug-in should work, but I can't figure out how to determine the URL of the CRM installation. I'm authoring this in a test environment and definitely don't want to have to change things when I move to production. I'm sure I could use a config file, but seems like the plug-in should be able to figure this out at runtime.
Anyone have any ideas how to access the URL of the crm service from within a plug-in? Any other ideas?
There is no simple way to do this. However, there is one.
The MSCRM_Config is the deployment database that handle physical deployment properties, like the URL from which users are accessing the CRM deployment. The url that you might want is the one stored in "ADWebApplicationRootDomain", in the MSCRM_CONFIG.dbo.DeploymentProperties table. You may need some permission to access this database.
Note that this doesn't work in a deployment that is an Internet Facing Deployment.
Another way could be to query the discovery service to retrieve the same information (in the case that you are on the Online edition of MSCRM4).
What do you mean by "change things"?
If you create a custom workflow assembly, you can give it a server url input. Once you register it with CRM, you can simply type in the server url when you configure the workflow. You'll have to update the url for any workflows that use the custom workflow assembly once you move to production, but you'll only have to do that once.
My apologies if this is what you meant you wanted to avoid.
Edit: Sounds like you may be able to use the CustomConfiguration attribute when you register the plugin. Here's some more info.
http://blogs.msdn.com/crm/archive/2008/10/24/storing-configuration-data-for-microsoft-dynamics-crm-plug-ins.aspx
String Url = ((string)(Registry.LocalMachine.OpenSubKey(
"Software\\Microsoft\\MSCRM").GetValue("ServerUrl"))
).Replace("MSCRMServices", "");

Resources