Пример #1
0
        protected override Uri GetServiceLoginUrl(Uri returnUrl)
        {
            var builder = new UriBuilder(_authorizationEndpoint);
            var args    = new Dictionary <string, string>();

            args.Add("response_type", "code");
            args.Add("client_id", _appId);
            args.Add("redirect_uri", GoogleProviderAuthorizer.NormalizeHexEncoding(returnUrl.AbsoluteUri));
            args.Add("scope", string.Join(" ", this._scopes));
            GoogleProviderAuthorizer.AppendQueryArgs(builder, args);
            return(builder.Uri);
        }
Пример #2
0
        protected override string QueryAccessToken(Uri returnUrl, string authorizationCode)
        {
            var args = new Dictionary <string, string>();

            args.Add("response_type", "code");
            args.Add("code", authorizationCode);
            args.Add("client_id", _appId);
            args.Add("client_secret", _appSecret);
            args.Add("redirect_uri", GoogleProviderAuthorizer.NormalizeHexEncoding(returnUrl.AbsoluteUri));
            args.Add("grant_type", "authorization_code");
            string query = "?" + GoogleProviderAuthorizer.CreateQueryString(args);
            string data  = HttpPost(_tokenEndpoint, query);

            if (string.IsNullOrEmpty(data))
            {
                return(null);
            }
            JObject jObject = JObject.Parse(data);

            return((string)jObject["access_token"]);
        }