Created
January 29, 2014 21:23
-
-
Save wadewegner/8697510 to your computer and use it in GitHub Desktop.
Code used by the WindowsPhoneOAuth sample.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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('&'); | |
var accessToken = split[0].Split('=')[1]; | |
var instanceUrl = split[2].Split('=')[1]; | |
var url = string.Format("/MainPage.xaml?AccessToken={0}&InstanceUrl={1}", accessToken, instanceUrl); | |
return new Uri(url, UriKind.Relative); | |
} | |
return uri; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var url = | |
Common.FormatAuthUrl( | |
AuthorizationEndpointUrl, | |
ResponseTypes.Token, | |
ConsumerKey, | |
CallbackUrl, | |
DisplayTypes.Touch); | |
AuthBrowser.Navigate(new Uri(url)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void InitializePhoneApplication() | |
{ | |
... | |
RootFrame.UriMapper = new AssociationUriMapper(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var client = new ForceClient(InstanceUrl, AccessToken, ApiVersion); | |
var accounts = await client.Query<Account>("SELECT id, name, description FROM Account"); | |
OrganizationsList.ItemsSource = accounts; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Extensions> | |
<Protocol Name="sfdc" NavUriFragment="encodedLaunchUri=%s" TaskID="_default" /> | |
</Extensions> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment