public OAuthModule(IOAuth api) { _OAuth = api; Get["/SignIn"] = SignIn; Get["/SignOut"] = SignOut; Get["/callback"] = Callback; }
public async Task<string> Connect(IOAuth _authenticator) { SetUp("https://www.wunderlist.com/oauth/access_token"); if (WunderlistToken == null) { string url = "https://www.wunderlist.com/oauth/authorize?client_id=" + WunderlistId + "&redirect_uri=" + "https://developer.wunderlist.com" + "&state=PleasCopyThis"; string res = _authenticator.ActivateOAuth(new Uri(url), "https://developer.wunderlist.com"); string token = Regex.Match(res, "code=(.+)").Groups[1].Value; Auth auth = await MakeRequest<Auth>("", Call.POST, new List<Param> { new Param("client_id", WunderlistId), new Param("code", token), new Param("client_secret", WunderlistSecret) }); WunderlistToken = auth.access_token; } SetBaseUrl("https://a.wunderlist.com/api/v1/"); AddStandardHeader(new Param("X-Access-Token", WunderlistToken)); AddStandardHeader(new Param("X-Client-ID", WunderlistId)); return WunderlistToken; }
public async Task<string> Connect(IOAuth authenticator, string GeneralRedirectUrl) { SetUp("https://getpocket.com/v3/"); if (Pocket_access_token != null) { AddStandardParameter(new Param("access_token", Pocket_access_token)); AddStandardParameter(new Param("consumer_key", PocketKey)); return Pocket_access_token; } List<Param> parameters = new List<Param> { new Param("consumer_key", PocketKey), new Param("redirect_uri", "zeus://") }; IRestResponse resp = await HandleRequest("oauth/request.php", Call.POST, parameters: parameters); string code = resp.Content.Replace("code=", ""); authenticator.ActivateOAuth(new Uri("https://getpocket.com/auth/authorize?request_token=" + code + "&redirect_uri=" + GeneralRedirectUrl)); parameters = new List<Param> { new Param("consumer_key", PocketKey), new Param("code", code) }; resp = await HandleRequest("oauth/authorize.php", Call.POST, parameters: parameters); var noAccessToken = resp.Content.Replace("access_token=", ""); string accessToken = noAccessToken.Remove(30, resp.Content.Length - 13 - 30); return accessToken; }
/// <summary> /// 同步消息 /// </summary> /// <param name="authEnum">授权类型</param> /// <param name="accessToken">Access Token</param> /// <param name="accessSecret">Access Secret</param> /// <param name="text">消息</param> public static void SendText(OAuthEnum authEnum, string accessToken, string accessSecret, string text) { IOAuth auth = null; switch (authEnum) { case OAuthEnum.msn: auth = new MSNOAuth(); break; case OAuthEnum.sina: auth = new SinaOAuth(); break; case OAuthEnum.qq: auth = new QQOAuth(); break; case OAuthEnum.netease: auth = new NeteaseOAuth(); break; case OAuthEnum.sohu: auth = new SohuOAuth(); break; case OAuthEnum.kaixin: auth = new KaiXinOAuth(); break; case OAuthEnum.renren: auth = new RenRenOAuth(); break; } if (!auth.IsNull()) { auth.SendText(accessToken, accessSecret, text); } }
public EasyMSClient(IHttpClientFactory httpClientFactory, EasyMSAuthInfo authInfo) { AuthInfo = authInfo; var gateway = new EasyMSAPIGateway(httpClientFactory); OAuth = new OAuth(gateway); }
public void RefreshToken_Succeeds() { var client = new HarvestRestClient("harvestdotnet", "CuJ3af_hylkRp4NvDe20yg", "3_-0j6mRXPSjOmNcGn2q73BHexU11jxbbPiwBXnpX1oJ92Yj7Sb22UYuE4uKkc5zZYMtXg5s2BXZsfmWbFo0fg", null); IOAuth whatever = client.RefreshToken("Vjlz7xhW2p9HbzndrM0D1HnaGY7z0S1PKsXkHuQXD1xai4_GCe_fHLEqUgNfqy4Yeuize9KtBfZAo1g3TyMqmg"); Assert.NotNull(whatever); Assert.NotNull(whatever.AccessToken); }
/// <summary> /// Creates a new instance of the OAuthFacade class. /// </summary> /// <param name="oAuth"><see cref="IOAuth"/> instance.</param> /// <param name="clientData"><see cref="IClientData"/> instance.</param> /// <param name="userInfo">User's credentials.</param> public OAuthFacade(IOAuth oAuth, IClientData clientData, UserInfo userInfo) { this.oAuth = oAuth; this.clientData = clientData; this.userInfo = userInfo; ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12; ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true; }
public SessionController(ILogger <SessionController> logger, IUserRepository userRepository, IJwtAuth jwtAuth, IPasswordProvider passwordProvider, IOAuth oauth) { _logger = logger; _userRepository = userRepository; _jwtAuth = jwtAuth; _passwordProvider = passwordProvider; _oauth = oauth; }
public void User_ProvideAvatarUploadWebClient() { // ARRANGE string data = "some test data!"; IOAuth auth = FactoryClients.OAuthMock; IRequestBuilder builder = new DracoonRequestBuilder(auth); WebClient expected = FactoryClients.RequestBuilderMock.ProvideAvatarUploadWebClient(data); // ACT WebClient actual = builder.ProvideAvatarUploadWebClient(data); // ASSERT Assert.Equal(expected, actual, new WebClientComparer()); }
public async Task Connect(string outlookId, string redirectUrl, IOAuth authe) { var uri = new Uri("https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=" + outlookId + "&redirect_uri=" + redirectUrl + "&response_type=code&scope=https%3A%2F%2Foutlook.office.com%2FMail.ReadWrite+https%3A%2F%2Foutlook.office.com%2FCalendars.ReadWrite+" + "offline_access"); string return_url = authe.ActivateOAuth(uri); string login_code = return_url.Replace("code=",""); SetBaseUrl("https://outlook.office.com/api/v1.0/"); }
/// <summary> /// 取登录账号信息 /// </summary> /// <param name="authEnum">授权类型</param> /// <returns>取登录账号信息</returns> public static UserInfo GetUserInfo(OAuthEnum authEnum) { IOAuth auth = null; switch (authEnum) { case OAuthEnum.msn: auth = new MSNOAuth(); break; case OAuthEnum.sina: auth = new SinaOAuth(); break; case OAuthEnum.qq: auth = new QQOAuth(); break; case OAuthEnum.netease: auth = new NeteaseOAuth(); break; case OAuthEnum.sohu: auth = new SohuOAuth(); break; case OAuthEnum.kaixin: auth = new KaiXinOAuth(); break; case OAuthEnum.renren: auth = new RenRenOAuth(); break; } return(auth.IsNull() ? null : auth.GetUserInfo()); }
/// <summary> /// 取登录URL /// </summary> /// <param name="authEnum">授权类型</param> /// <returns>登录URL</returns> public static string GetAuthUrl(OAuthEnum authEnum) { IOAuth auth = null; switch (authEnum) { case OAuthEnum.msn: auth = new MSNOAuth(); break; case OAuthEnum.sina: auth = new SinaOAuth(); break; case OAuthEnum.qq: auth = new QQOAuth(); break; case OAuthEnum.netease: auth = new NeteaseOAuth(); break; case OAuthEnum.sohu: auth = new SohuOAuth(); break; case OAuthEnum.kaixin: auth = new KaiXinOAuth(); break; case OAuthEnum.renren: auth = new RenRenOAuth(); break; } return(auth.IsNull() ? string.Empty : auth.GetAuthUrl()); }
/// <summary> /// 取登录账号好友信息 /// </summary> /// <param name="authEnum">授权类型</param> /// <param name="accessToken">Access Token</param> /// <param name="accessSecret">Access Secret</param> /// <returns>取登录账号好友信息</returns> public static IList <UserInfo> GetFriendsInfo(OAuthEnum authEnum, string accessToken, string accessSecret) { IOAuth auth = null; switch (authEnum) { case OAuthEnum.msn: auth = new MSNOAuth(); break; case OAuthEnum.sina: auth = new SinaOAuth(); break; case OAuthEnum.qq: auth = new QQOAuth(); break; case OAuthEnum.netease: auth = new NeteaseOAuth(); break; case OAuthEnum.sohu: auth = new SohuOAuth(); break; case OAuthEnum.kaixin: auth = new KaiXinOAuth(); break; case OAuthEnum.renren: auth = new RenRenOAuth(); break; } return(auth.IsNull() ? null : auth.GetFriendsInfo(accessToken, accessSecret)); }
public ExchangeUrl(IOAuth oauth) { this.oauth = oauth; this.options = new List<string>(); }
public PublishService(IOAuth oAuth) { OAuth = oAuth; }
public OauthController() { _oauth = new OAuth(); _gigyaService = new GiayaService(); }
public DoubanClient(IOAuth auth) : base(auth) { _openApi = new OpenApi(this); }
public SignInViewModel(IOAuth oAuth, ISession session) : base("SignIn", session) { OAuthUrl = oAuth.GetAuthUrl(); }
/** * Set the delegate implementation. * * @param _delegate The delegate implementing platform specific functions. */ public void SetDelegate(IOAuth _delegate) { this._delegate = _delegate; }
/** * Constructor with delegate. * * @param _delegate The delegate implementing platform specific functions. */ public OAuthBridge(IOAuth _delegate) : base() { this._delegate = _delegate; }
public OAuth2Controller(IOAuth context) { _context = context; }
internal DracoonRequestExecutor(IOAuth auth, IInternalDracoonClient client) { _auth = auth; _client = client; }
public void Connect(IOAuth _authenticator) { var url = "https://github.com/login/oauth/authorize?redirect_uri=" + _authenticator.RedirectUrl() + "&client_id=" + GitHub_clientID + "&scope=repo,notifications,admin:org"; _authenticator.ActivateOAuth(new Uri(url)); }
protected BaseClient( IOAuth auth ) { OAuth = auth; }
internal DracoonRequestBuilder(IOAuth auth) { _auth = auth; }
private static TokenResponse GenerateAccessTokenResponse(IUserTokenRepository userTokenRepository, IOAuth appSettingsOAuth, long userId, string userRole, string username) { string nonce = GenerateNonce(); string accessToken = GenerateAccessToken( userId: userId, userRole: userRole, nonce: nonce, secretKey: appSettingsOAuth.SecretKey, issuer: appSettingsOAuth.Issuer, expiresAfter: appSettingsOAuth.AccessTokenExpires); string refreshToken = GenerateRefreshToken(); string checksum = (refreshToken + username).GetSHA256HashString(); userTokenRepository.Add(refreshToken, userId, nonce, appSettingsOAuth.RefreshTokenExpires, checksum); userTokenRepository.RemoveExpired(); return(new TokenResponse { AccessToken = accessToken, TokenType = "bearer", ExpiresIn = appSettingsOAuth.AccessTokenExpires, RefreshToken = refreshToken }); }
public Auth() { this._oauth = new OAuth(); }
private void client_AuthoriseCompleted(IOAuth client, IAuthorisationResult authoriseResult) { if (authoriseResult.Success) { authResult = authoriseResult; //Allow tokens to be used if token was returned. btnUseToken.Enabled = true; } else { MessageBox.Show(authoriseResult.Error); } if (client != null) { client.Dispose(); } }