private async void ExchangeAuthorizationCode(OAuthAuthorizationCode code) { var oauthToken = await _oauthService.ExchangeAuthorizationCodeAsync(code); _sfClient.AddOAuthCredentials(oauthToken); _sfClient.BaseUri = oauthToken.GetUri(); var session = await _sfClient.Sessions.Login().Expand("Principal").ExecuteAsync(); MessageBox.Show("User: "******"Successful"); }
async Task <IShareFileClient> BuildShareFileClient(OAuthAuthorizationCode authCode) { string baseUriFormat = "https://{0}.{1}/sf/v3"; string baseUri = String.Format(baseUriFormat, authCode.Subdomain, authCode.ApiControlPlane); IShareFileClient api = new ShareFileClient(baseUri); var oauth = new OAuthService(api, Globals.OAuthClientID, Globals.OAuthClientSecret); var token = await oauth.ExchangeAuthorizationCodeAsync(authCode); api.AddOAuthCredentials(token); api.BaseUri = new Uri(String.Format(baseUriFormat, token.Subdomain, token.ApiControlPlane)); await Login(api); return(api); }
internal static IOAuthResponse ToOAuthResponse(this Dictionary <string, string> value) { IOAuthResponse response; if (value.ContainsKey("code")) { response = new OAuthAuthorizationCode(); } else if (value.ContainsKey("access_token")) { response = new OAuthToken(); } else if (value.ContainsKey("error")) { response = new OAuthError(); } else { response = new OAuthResponseBase(); } response.Fill(value); return(response); }