Skip to content

Instantly share code, notes, and snippets.

View LindaLawton's full-sized avatar
🎯
Focusing

Linda Lawton LindaLawton

🎯
Focusing
View GitHub Profile
@LindaLawton
LindaLawton / Google drive insert permissions Csharp
Last active May 10, 2019 08:55
How to add permissions to a file or folder on Google drive in C#
/// <summary>
/// Insert a new permission.
/// </summary>
/// <param name="service">Drive API service instance.</param>
/// <param name="fileId">ID of the file to insert permission for.</param>
/// <param name="who">
/// User or group e-mail address, domain name or null for "default" type.
/// </param>
/// <param name="type">The value "user", "group", "domain" or "default".</param>
/// <param name="role">The value "owner", "writer" or "reader".</param>
@LindaLawton
LindaLawton / PHP Service account Google Analytics
Created August 28, 2015 07:49
Google analytics Service Account with PHP
<?php
require_once 'Google/autoload.php';
session_start();
/************************************************
The following 3 values an befound in the setting
for the application you created on Google
Developers console. Developers console.
The Key file should be placed in a location
that is not accessable from the web. outside of
web root. web root.
@LindaLawton
LindaLawton / WebMaster Tools API authentcation
Last active September 16, 2015 17:47
WebMaster Tools API authentcation
/// <summary>
/// Authenticate to Google Using Oauth2
/// Documentation https://developers.google.com/accounts/docs/OAuth2
/// </summary>
/// <param name="clientId">From Google Developer console https://console.developers.google.com</param>
/// <param name="clientSecret">From Google Developer console https://console.developers.google.com</param>
/// <param name="userName">A string used to identify a user.</param>
/// <returns></returns>
public static WebmastersService AuthenticateOauth(string clientId, string clientSecret, string userName)
{
@LindaLawton
LindaLawton / Wix SSIS installer
Last active October 7, 2015 09:28
Wix installer for custom ssis tasks.
<?xml version="1.0" encoding="UTF-8"?>
<Wix
xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="Daimto for SSIS (SQL Server 2008)" Language="1033" Version="1.0.0.0"
Manufacturer="DAIMTO" UpgradeCode="84543418-55c4-48c0-b5be-2496fb84ffb6">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perUser"
InstallPrivileges="elevated" AdminImage="yes" />
<MediaTemplate EmbedCab="yes" CompressionLevel="high" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
@LindaLawton
LindaLawton / GetAuthURI
Last active October 19, 2015 07:40
Creates the auth url
/// <summary>
/// Creates the auth url
/// https://accounts.google.com/o/oauth2/auth?client_id={clientid}&amp;redirect_uri=urn:ietf:wg:oauth:2.0:oob&amp;scope={scope}&amp;response_type=code
/// client id from google developer console.
/// scope comma seproated
/// </summary>
/// <returns></returns>
public static Uri GetAuthURI()
{
return new Uri(string.Format("https://accounts.google.com/o/oauth2/auth?client_id={0}&redirect_uri=urn:ietf:wg:oauth:2.0:oob&scope={1}&response_type=code", Properties.Resources.clientId, Properties.Resources.scope));
@LindaLawton
LindaLawton / exchangeCode
Last active October 19, 2015 07:55
exchanges the authetncation code for the refreshtoken and access token
class TokenResponse
{
public string access_token { get; set; }
public string token_type { get; set; }
public string expires_in { get; set; }
public string refresh_token { get; set; }
}
/// <summary>
@LindaLawton
LindaLawton / getAcccessToken
Last active October 19, 2015 07:54
takes a refreshtoken and exchanges it for an accessotken.
class AccessTokenResponse
{
public string access_token { get; set; }
public string token_type { get; set; }
public string expires_in { get; set; }
}
/// <summary>
/// takes a refreshtoken and exchanges it for an accessotken.
/// </summary>
private void auth()
{
webBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(GetTitle);
webBrowser1.Navigate(SimpleAuth.GetAuthURI().ToString());
}
/// <summary>
@LindaLawton
LindaLawton / 0_reuse_code.js
Created November 5, 2015 13:14
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@LindaLawton
LindaLawton / GoogleDriveV3.About.get
Last active March 10, 2016 10:52
Gets information about the user, the user's Drive, and system capabilities.
/// <summary>
/// Name: Get
/// Description: Gets information about the user, the user's Drive, and system capabilities.
/// Documentation: https://developers.google.com/drive/v3/reference
/// Service must be authentcated with one of the following scopes:
/// DriveService.Scope.Drive: View and manage the files in your Google Drive
/// DriveService.Scope.DriveAppdata: View and manage its own configuration data in your Google Drive
/// DriveService.Scope.DriveFile: View and manage Google Drive files and folders that you have opened or created with this app
/// DriveService.Scope.DriveMetadata: View and manage metadata of files in your Google Drive
/// DriveService.Scope.DriveMetadataReadonly: View metadata for files in your Google Drive