public static Uri GetAuthorizeUri(OAuthResponseTypeExact oauthResponseType, string clientId, Uri redirectUri, bool forceLogin = false, Region region = Region.Netherlands) { if (string.IsNullOrWhiteSpace(clientId)) { throw new ArgumentNullException("clientId"); } else if (redirectUri == null) { throw new ArgumentNullException("redirectUri"); } else if (oauthResponseType != OAuthResponseTypeExact.Code) { throw new ArgumentNullException("responseType"); } var dict = new Dictionary<string, string>(); var queryBuilder = new StringBuilder(); queryBuilder.Append("response_type="); switch (oauthResponseType) { case OAuthResponseTypeExact.Code: queryBuilder.Append("code"); break; default: throw new ArgumentOutOfRangeException("oauthResponseType"); } queryBuilder.Append("&client_id=").Append(Uri.EscapeDataString(clientId)); if (redirectUri != null) { queryBuilder.Append("&redirect_uri=").Append(Uri.EscapeDataString(redirectUri.ToString())); } string url = String.Concat(ExactOnlineSite(region), Auth); var uriBuilder = new UriBuilder(url); uriBuilder.Query = queryBuilder.ToString(); return uriBuilder.Uri; }
public static Uri GetAuthorizeUri(OAuthResponseTypeExact oauthResponseType, string clientId, string redirectUri, bool forceLogin = false, Region region = Region.Netherlands) { var uri = string.IsNullOrEmpty(redirectUri) ? null : new Uri(redirectUri); return GetAuthorizeUri(oauthResponseType, clientId, uri, forceLogin, region); }