我在我的应用中使用谷歌驱动器API。用于上传和下载文件。当我尝试同时上传不同计算机的文件时。我收到了这个错误。
public static IAuthenticator CreateAuthenticator()
{
var provider = new NativeApplicationClient(GoogleAuthenticationServer.Description);
provider.ClientIdentifier = CASNameScrollGeneral.GOOGLE_CLIENT_ID;
provider.ClientSecret = CASNameScrollGeneral.GOOGLE_CLIENT_SECRET;
return new OAuth2Authenticator<NativeApplicationClient>(provider, GetAuthorization);
}
private static IAuthorizationState GetAuthorization(NativeApplicationClient client)
{
string scope = DriveService.Scopes.Drive.ToString();
IAuthorizationState state = new AuthorizationState(scope.Split(new[] { ' ' }, System.StringSplitOptions.RemoveEmptyEntries)) { RefreshToken = CASNameScrollGeneral.GOOGLE_myRefresh };
if (state != null)
{
client.RefreshToken(state);
return state;
}
return null;
}
public static void CreateService(ref DriveService Serv)
{
string CLIENT_ID = CASNameScrollGeneral.GOOGLE_CLIENT_ID;
string CLIENT_SECRET = CASNameScrollGeneral.GOOGLE_CLIENT_SECRET;
string SCOPE = "https://docs.google.com/feeds/ https://docs.googleusercontent.com/ https://spreadsheets.google.com/feeds/";
string REDIRECT_URI = CASNameScrollGeneral.GOOGLE_REDIRECT_URI;
string myToken = CASNameScrollGeneral.GOOGLE_myToken;
string myRefresh = CASNameScrollGeneral.GOOGLE_myRefresh;
/* parameters.ClientId = CLIENT_ID;
parameters.ClientSecret = CLIENT_SECRET;
parameters.RedirectUri = REDIRECT_URI;
parameters.Scope = SCOPE;
parameters.AccessToken = myToken;
parameters.RefreshToken = myRefresh;
string authorizationUrl = OAuthUtil.CreateOAuth2AuthorizationUrl(parameters);
*/
//parameters.AccessCode = myRefresh;
//OAuthUtil.GetAccessToken(parameters);
//string accessToken = parameters.AccessToken;
Serv = new DriveService(CreateAuthenticator());
}
这是我的服务代码。谢谢你的帮助。