나는 내 응용 프로그램과 함께 Google 드라이브 연결과 같은 문제가 있었지만 지금은 하나 개의 솔루션을 발견하는 절대적으로 작업 벌금 나를. Googles Client lib가 너를 위해이 모든 것을 처리합니다. 누녜 패키지 Google.GData.Client 및 Google.GData.Documents를 다운로드하십시오. 당신이 다음 코드를 가지고 페이지 (의 Oauth 리디렉션 페이지) 3)에 돌아왔다 내 코드
parameters = new OAuth2Parameters()
{
ClientId = "CLIENT_ID",
ClientSecret = "CLIENT_SECRET",
RedirectUri = currentURL,//"http://localhost:6600/Home.html",
Scope = "https://docs.google.com/feeds/ ",
State = "documents",
AccessType = "offline", // offline means it creats a refreshtoken
TokenExpiry = DateTime.Now.AddYears(1)
};
string url = Google.GData.Client.OAuthUtil.CreateOAuth2AuthorizationUrl(parameters);
1) 여기에 사용자가 그래서 여기 2 페이지를 리디렉션 자신의 계정으로 로그인해야합니다) 다음
URL에서 상태 (QueryString을) 4) 페이지로드 이벤트 (서버로 전송) 5) 당신에게 여기) 코드를 Page_Load 이벤트 (첫 번째 코드 변수에 쿼리 문자열)
OAuth2Parameters parameters = new OAuth2Parameters()
{
ClientId = "274488228041-1aaq8a069h3c7lsjstsl394725tumdlo.apps.googleusercontent.com",
ClientSecret = "Ew1EMwe4EB8oLHvKFfDZxQhp",
RedirectUri = currentURL,//"http://localhost:6600/Home.html"
Scope = "https://docs.google.com/feeds/ ",
State = "documents",
AccessType = "offline", // offline means it creats a refreshtoken
TokenExpiry = DateTime.Now.AddYears(1)
};
parameters.AccessCode = code;
Google.GData.Client.OAuthUtil.GetAccessToken(parameters);
1을 얻을 다음 쓰기 accesstoken 얻을
GOAuth2RequestFactory requestFactory = new GOAuth2RequestFactory(null, "Infactum", parameters);
DocumentsService service = new DocumentsService("Infactum");
service.RequestFactory = requestFactory;
//requestFactory.CustomHeaders["Authorization"] = "Bearer " + parameters.AccessToken;
DocumentsListQuery query = new DocumentsListQuery();
query.NumberToRetrieve = 2000;
// Make a request to the API and get all documents.
DocumentsFeed feed = service.Query(query);
여기 Google 드라이브 문서에 액세스하는 매개 변수) 2 requesttoken 미래의 목적 (오프라인 액세스) 3 데이터베이스에 저장) 전달합니다, 당신은 공급 대상 2000 모든 유형의 파일을 얻을 것이다 당신 feed.entries를 사용하여 파일에 액세스 할 수 있습니다 ... 희망 하시길 바랍니다
API 문서는 무엇을 말하고 있습니까? 너 뭐 해봤 니? –