Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="code">The authorization code we get from service when user provides valid credentials. It is sent to the service to get the access token.</param>
        /// <returns></returns>
        public ActionResult GetAccessToken(string code)
        {
            string callbackUrl = Url.Action("GetAccessToken", "Oauth2", null, Request.Url.Scheme, Request.Url.Host);

            ILogger Logger = new PepperiLogger();
            PublicAuthentication PublicAuthentication = new PublicAuthentication(Logger, Settings.OauthBaseUri, Settings.PublicApplication_ConsumerKey, Settings.PublicApplication_ConsumerSecret);
            Oauth2Token          Oauth2Token          = PublicAuthentication.GetAccessTokenByAuthorizationCode(code, callbackUrl, "READ", new TokenRepository(this.Session));

            return(RedirectToAction("Transactions", "Transaction"));
        }
Пример #2
0
        public ActionResult GetAuthorizationCode()
        {
            string callbackUrl = Url.Action("GetAccessToken", "Oauth2", null, Request.Url.Scheme, Request.Url.Host);

            ILogger Logger = new PepperiLogger();
            PublicAuthentication PublicAuthentication = new PublicAuthentication(Logger, Settings.OauthBaseUri, Settings.PublicApplication_ConsumerKey, Settings.PublicApplication_ConsumerSecret);
            string AuthorizationUrl = PublicAuthentication.GetAuthorizationUrl(callbackUrl, "READ");

            return(Redirect(AuthorizationUrl));
        }