public void GetCode(OauthUI ui, object owner) { port = GetFirstAvailableRandomPort(MinPortRange, MaxPortRange); redirectURI = string.Format(LoopbackCallback, port) + "/"; authorizationRequest = string.Format("https://www.dropbox.com/1/oauth2/authorize?client_id={0}&response_type=code&redirect_uri=http%3A%2F%2Flocalhost%3A{1}", DropboxAppKey.ApiKey, port.ToString()); ui.EventUriResponse += Ui_EventUriResponse; GetCode_(ui, owner); }
//Process Cloud_Oauth; internal void GetCode_(OauthUI ui, object owner) { if (string.IsNullOrEmpty(authorizationRequest) | string.IsNullOrEmpty(redirectURI)) { throw new Exception("Oauth:authorizationRequest or redirectURI is null."); } //Cloud_Oauth = Process.Start(Directory.GetCurrentDirectory() + "\\Cloud_Oauth.exe", redirectURI); //Cloud_Oauth.OutputDataReceived += Cloud_Oauth_OutputDataReceived; ui.Url = authorizationRequest; ui.CheckUrl = redirectURI; ui.ShowUI(owner); }
public void GetCode(OauthUI ui, object owner) { state = randomDataBase64url(32); code_verifier = randomDataBase64url(32); code_challenge = base64urlencodeNoPadding(sha256(code_verifier)); string scopepara = Scope.GetParameters(this.default_scopes); redirectURI = string.Format("http://{0}:{1}/", IPAddress.Loopback, GetRandomUnusedPort()); authorizationRequest = string.Format("{0}?response_type=code&scope={1}&redirect_uri={2}&client_id={3}&state={4}&code_challenge={5}&code_challenge_method={6}", authorizationEndpoint, scopepara, Uri.EscapeDataString(redirectURI), GoogleDriveAppKey.ClientID, state, code_challenge, code_challenge_method); ui.EventUriResponse += Ui_EventUriResponse; GetCode_(ui, owner);//,new HttpListenerContextRecieve(Rev)); }