コード例 #1
0
        public string CreateAuthorizationRequest()
        {
            // Create URI to authorization endpoint
            var authorizeRequest = new AuthorizeRequest(GlobalSetting.Instance.IdentityEndpoint);

            // Dictionary with values for the authorize request
            var dic = new Dictionary <string, string>();

            dic.Add("client_id", GlobalSetting.Instance.ClientId);
            dic.Add("client_secret", GlobalSetting.Instance.ClientSecret);
            dic.Add("response_type", "code id_token");
            dic.Add("scope", "openid profile basket orders locations marketing offline_access");
            dic.Add("redirect_uri", GlobalSetting.Instance.IdentityCallback);
            dic.Add("nonce", Guid.NewGuid().ToString("N"));
            dic.Add("code_challenge", CreateCodeChallenge());
            dic.Add("code_challenge_method", "S256");

            // Add CSRF token to protect against cross-site request forgery attacks.
            var currentCSRFToken = Guid.NewGuid().ToString("N");

            dic.Add("state", currentCSRFToken);

            var authorizeUri = authorizeRequest.Create(dic);

            return(authorizeUri);
        }
コード例 #2
0
        public string CreateAuthorizeRequest()
        {
            // Create URI to authorize endpoint
            var authorizeRequest =
                new AuthorizeRequest(GlobalSetting.Instance.IdentityEndpoint);

            // Dictionary with values for the authorize request
            var dic = new Dictionary <string, string>();

            dic.Add("client_id", "xamarin");
            dic.Add("response_type", "id_token token");
            dic.Add("scope", "openid profile basket orders");

            dic.Add("redirect_uri", GlobalSetting.Instance.IdentityCallback);
            dic.Add("nonce", Guid.NewGuid().ToString("N"));

            // Add CSRF token to protect against cross-site request forgery attacks.
            var currentCSRFToken = Guid.NewGuid().ToString("N");

            dic.Add("state", currentCSRFToken);

            var authorizeUri = authorizeRequest.Create(dic);

            return(authorizeUri);
        }