是否有任何桌面应用程序的代码示例如何授权Google Drive服务并上传文件?
目前我有:
var parameters = new OAuth2Parameters
{
ClientId = ClientCredentials.ClientId,
ClientSecret = ClientCredentials.ClientSecret,
RedirectUri = ClientCredentials.RedirectUris[0],
Scope = ClientCredentials.GetScopes()
};
string url = OAuthUtil.CreateOAuth2AuthorizationUrl(parameters);
// Open url, click to allow and copy secret code
parameters.AccessCode = secretCodeFromBrowser;
OAuthUtil.GetAccessToken(parameters);
string accessToken = parameters.AccessToken;
// So, there is the access token
Run Code Online (Sandbox Code Playgroud)
但接下来的步骤是什么?正如我从示例中看到的,我应该获得IAuthenticator实例并将其传递给DriveService类的构造函数...如何获取IAuthenticator的实例?如果我的上述代码是正确的...提前谢谢.
我试过了:
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:dd/MM/yyyy}", ConvertEmptyStringToNull = true)]
[Required(AllowEmptyStrings = true)]
public DateTime? BirthDateFrom { get; set; }
Run Code Online (Sandbox Code Playgroud)
和
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:dd/MM/yyyy}")]
[Required]
public DateTime? BirthDateFrom { get; set; }
Run Code Online (Sandbox Code Playgroud)
和有和没有ConvertEmptyStringToNull和的所有组合AllowEmptyStrings.
在视图中,我有:
@Html.EditorFor(m => m.BirthDateFrom)
Run Code Online (Sandbox Code Playgroud)
我可以提交带有效日期的表单,但在该字段中有空字符串,它只是变红并且表单无法提交.如何在所需的可为空的DateTime中允许使用null或空字符串值的HTML表单提交?