Skip to content

Instantly share code, notes, and snippets.

View wadewegner's full-sized avatar

Wade Wegner wadewegner

View GitHub Profile
@wadewegner
wadewegner / TestRefreshToken.cs
Created February 5, 2014 20:12
A simple demonstration of retry logic to simulate handling an invalid token and using the refresh token
_token.AccessToken = "GARBAGE"; // simulates the same behavior as expiration
var refreshToken = false;
do
{
if (refreshToken)
{
var auth = new AuthenticationClient();
await auth.TokenRefreshAsync(ConsumerKey, _token.RefreshToken);
@wadewegner
wadewegner / CallTokenRefreshAsync.cs
Created February 5, 2014 16:49
Code used by the Salesforce Toolkits for .NET to perform a token refresh
var auth = new AuthenticationClient();
await auth.TokenRefreshAsync(ConsumerKey, _token.RefreshToken);
@wadewegner
wadewegner / JekyllLinterUpdate.sh
Created February 3, 2014 18:21
I needed a way to refresh the Facebook meta data for all my Jekyll blog posts. This solution provided the easiest (and fastest) solution.
---
layout: nil
---
#!/bin/bash
{% for post in site.posts %}$(/usr/bin/open -a "/Applications/Google Chrome.app" 'https://developers.facebook.com/tools/debug/og/object?q=http://www.wadewegner.com{{ post.url }}')
{% endfor %}
@wadewegner
wadewegner / WebAuthenticationBroker.cs
Last active August 29, 2015 13:55
Sample code for using the WebAuthorizationBroker to authenticate with Salesforce.com using the User Agent auth flow.
private const string AuthorizationEndpointUrl =
"https://login.salesforce.com/services/oauth2/authorize";
private const string ConsumerKey = "YOURCONSUMERKEY";
private const string CallbackUrl = "sfdc://success";
async private void Page_Loaded(object sender, RoutedEventArgs e)
{
var startUrl = Common.FormatAuthUrl(AuthorizationEndpointUrl, ResponseTypes.Token, ConsumerKey,
WebUtility.UrlEncode(CallbackUrl), DisplayTypes.Popup);
var startUri = new Uri(startUrl);
@wadewegner
wadewegner / AssociationUriMapper.cs
Created January 29, 2014 21:23
Code used by the WindowsPhoneOAuth sample.
class AssociationUriMapper : UriMapperBase
{
public override Uri MapUri(Uri uri)
{
var tempUri = System.Net.HttpUtility.UrlDecode(uri.ToString());
if (tempUri.Contains("sfdc://success"))
{
var querystring = tempUri.Substring(tempUri.IndexOf("#") + 1);
var split = querystring.Split('&');
@wadewegner
wadewegner / gettoken.lua
Last active December 28, 2015 22:18
Simple Lua script for making a token request against the Force.com REST APIs.
local secretKey = "YOUR_SECRET_KEY"
local data = {
client_id = "YOUR_CONSUMER_KEY",
client_secret = "YOUR_CONSUMER_SECRET",
grant_type = "password",
username = "YOUR_LOGIN",
password = "YOUR_PASSWORD" .. secretKey
}
@wadewegner
wadewegner / gettoken_local.py
Last active February 24, 2023 00:39
Simple Python scripts for making a token request against the Force.com REST APIs. The first does not include the security token and the second does. You will want to use the second one.
import requests
consumer_key = "YOUR_CONSUMER_KEY"
consumer_secret = "YOUR_CUSTOMER_SECRET"
username = "YOUR_USER_NAME"
password = "YOUR_PASSWORD"
payload = {
'grant_type': 'password',
'client_id': consumer_key,
@wadewegner
wadewegner / QueryBuilder.reg
Created October 21, 2013 18:02
Enable Query Builder in Outlook 2013
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\Outlook\QueryBuilder]
@wadewegner
wadewegner / WAIIASWebFarm1
Created March 4, 2013 05:42
PowerShell scripts supporting post "Using Windows Azure Virtual Machines to Publish and Synchronize a Web Farm" found here: http://www.wadewegner.com/2013/03/using-windows-azure-virtual-machines-to-publish-and-synchronize-a-web-farm/
$imgname = 'WS2012-WebFarmImage'
$cloudsvc = 'DemoWebFarm'
$pass = 'Password'
$subscriptionName = 'Windows Azure MSDN - Visual Studio Ultimate'
$storageAccount = 'portalvhds9dvbvvff5hdg3'
$location = 'East US'
Set-AzureSubscription -SubscriptionName $subscriptionName -CurrentStorageAccount $storageAccount
$iisvm1 = New-AzureVMConfig -Name 'iis1' -InstanceSize Small -ImageName $imgname |
@wadewegner
wadewegner / gist:4047128
Created November 9, 2012 17:50
Call Parse Cloud Code from WinRT
var parameters = new Dictionary<string, object> { { "message", "Hello!" } };
await ParseCloud.CallFunctionAsync<IDictionary<string, object>>("sendsms", parameters);