/// <summary> /// Create access token /// </summary> public static OauthAccessToken Create( OauthGrantType grantType, string authCode, string redirectUri, OauthClient client ) { HttpClient apiClient = new HttpClient(); HttpResponseMessage responseRaw = apiClient.PostAsync( CreateTokenUri(grantType, authCode, redirectUri, client), null ).Result; return(BunqJsonConvert.DeserializeObject <OauthAccessToken>(responseRaw.Content.ReadAsStringAsync().Result)); }
/// <summary> /// Create token URI string. /// </summary> protected static string CreateTokenUri( OauthGrantType grantType, string authCode, string redirectUri, OauthClient client ) { Dictionary <string, string> allTokenParameter = new Dictionary <string, string>() { { FIELD_GRANT_TYPE, grantType.TypeString }, { FIELD_CODE, authCode }, { FIELD_REDIRECT_URI, redirectUri }, { FIELD_CLIENT_ID, client.ClientId }, { FIELD_CLIENT_SECRET, client.Secret }, }; return(String.Format(DetermineTokenUriFormat(), HttpUtils.CreateQueryString(allTokenParameter))); }