Authenticationtokencreatecontext



I am using the Web Api 2 template that comes with Visual Studio 2013 has some OWIN middleware to do User Authentication and the likes of. C# (CSharp) AuthenticationTicket - 23 examples found.These are the top rated real world C# (CSharp) examples of AuthenticationTicket extracted from open source projects. You can rate examples to help us improve the quality of examp. Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time. In the last post I showed how to add a simple username/password (aka resource owner password credentials flow) authorization server to Web API v2. This has several advantages: The client does not need to hold on to the user credentials after the token has been requested (e.g. For re-submitting them on every request) The user.

It seems that the refresh token has the same expiration time as the access token. So you'll need to extend the expiration of the refresh token:

-- Update --

I've updated the code to answer the question in your comment. It's more than you've asked for. But I think it will help to explain.

It all depends on the requirement and chosen strategy. To explain the code:

Each time an access token is issued you will also hit this piece of code which will add a refresh token. In this strategy I will issue a new refresh token only when grant_type is not 'refresh_token'. This means that at some point the refresh token expires and the user has to login again.

In the example the user has to login every day again. But if the user logs in before the refresh_token expires, a new refresh token will be issued. That way the refresh token has an absolute expiration time, forcing the user to login at least once a day.

If you want 'sliding expiration', you can add a refresh token every time you issue an access token. Please note that the user may never have to login again, unless the refresh token expires before refreshing.

Authenticationtokencreatecontext

In any case I wouldn't block users from creating access tokens when grant_type is not refresh_token. Since that is user interaction. The access token has a very limited window (think of hours or minutes, not days), so it will expire soon enough. You do not want to validate an access token each time you receive it in a header, since this means you'll need to check the database for each call.

Instead think of a strategy to invalidate 'old' refresh tokens. You could save the hashed version of the last refresh token in the database. If it doesn't match then respond with an 'invalid_grant' error.

I'm learning OAuth2 via this tutorial, then I found refresh token's expire time is the same as access token, is this correct?

That's true: refresh tokens issued by the OAuth2 authorization server built in OWIN/Katana always have the same expiration date as access tokens ; even if you specify an explicit ExpiresUtc property in AuthenticationProperties when you call IOwinContext.Authentication.SignIn(identity, properties)

That's not really convenient for the reasons @Hans mentioned but you can override this behavior in AuthenticationTokenProvider.CreateAsync (the class you use for OAuthAuthorizationServerOptions.RefreshTokenProvider):

Simply set context.Ticket.Properties.ExpiresUtc with the expiration date of your choice, and the refresh token will be issued with a different expiration date:

You can also take a look at AspNet.Security.OpenIdConnect.Server, a fork of the OAuth2 authorization server offered by OWIN/Katana that has a native RefreshTokenLifetime: https://github.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Server/tree/dev

Don't hesitate to ping me if you need help.

How to make a website work only with https [duplicate]

asp.net,ssl,https

Sure, assuming you are using IIS to host your site, open IIS Manager and select your web site and then binding on the right: make sure you only have a binding for https not for http. This way IIS will only send https traffic to that web site. Edit: What...

Server side session in asp.net

asp.net,web-services,session

You've got a quotes problem, fix it like this: <% Session['path'] = '' + vr_ + ''; %> EDIT 1: Javascript and ASP.NET are not the same, so you cannot access the variables, so you can't do it on the client side. You must send something to the server like...

Catch concurrency exception in EF6 to change message to be more user friendly

c#,asp.net,.net,entity-framework,entity-framework-6

You are executing an asynchronous method. This means that any exceptions will be thrown when you call await on the returned task or when you try to retrieve the results using await myTask; You never do so, which means that the exception is thrown and caught higher up your call...

Access manager information from Active Directory

c#,asp.net,active-directory

try this: var loginName = @'loginNameOfInterestedUser'; var ldap = new DirectoryEntry('LDAP://domain.something.com'); var search = new DirectorySearcher(ldap) { Filter = '(&(objectCategory=person)(objectClass=user)(sAMAccountName=' + loginName + '))' }; var result = search.FindOne(); if (result null) return; var fullQuery = result.Path; var user = new DirectoryEntry(fullQuery); DirectoryEntry manager; if (user.Properties.PropertyNames.OfType<string>().Contains('manager')) { var managerPath...

IIS 6 Allow anonymous access by default

asp.net,iis,website,iis-6

The solution is to force IIS to write the changes from the cache into the Metabase.xml, this way the new configurations will be available for editing. This is done using the command - %systemroot%system32IIsCnfg.vbs /save ...

Convert Double from String

asp.net,vb.net,visual-studio-2012,converter

The result isn't wrong, it only has lower precision than you expected. Floating point numbers have a limited precision by design, and you simply can't expect to get a result that is more precise than its limit. You can use a Decimal to get higher precision. In this case it...

Serializeticket

Can I uniquely identify 2 check boxes so that I can add a different image to each?

html,css,asp.net,checkbox

Here is an example of what I meant: (Oh and, forgive the images please :) ) #field1,#field2{ display:none; } #field1 + label { padding:40px; padding-left:100px; background:url(http://www.clker.com/cliparts/M/F/B/9/z/O/nxt-checkbox-unchecked-md.png) no-repeat left center; background-size: 80px 80px; } #field1:checked + label { background:url(http://www.clker.com/cliparts/B/2/v/i/n/T/tick-check-box-md.png) no-repeat left center; background-size: 80px 80px; } #field2 + label { padding:40px;...

Cannot start Website in IIS - W3SVC running

asp.net,iis

First verify that the World Wide Web Publishing Service is installed and not disabled. [Source:MSDN] Right-click My Computer on the desktop, and then click Manage. Expand the Services and Applications node, and then click the Services node. In the right pane, locate the World Wide Web Publishing Service. If the...

.NET wep api won't accept %2E or . in api request uri

c#,jquery,asp.net,ajax,json

Authenticationtokencreatecontext serializeticket

Have a look at this answer MVC4 project - cannot have dot in parameter value? Try changing the Web.Config file <system.web> <httpRuntime relaxedUrlToFileSystemMapping='true' /> </system.web> ...

How do ASP.NET Web APIs work once built with MSBUILD?

c#,asp.net,msbuild

The WebApi is a web project and on compiling it creates a dll. It is not a class library or a nuget package to consume and use it. I have practically implemented this in a real world application and below are my thoughts for your understanding. Your question is Once...

How to format label in ASP.net chart control

c#,asp.net,asp.net-mvc,c#-4.0,reporting-services

Use formatting: DateTime.Now.ToString('dddd, dd-MM-yy'); Output: Montag, 15-06-15 //Written day of week in your local culture. To edit the axis labeling, you can do it in your code-behind file: Chart1.ChartAreas[0].AxisX.LabelStyle.Format = 'dddd, dd-MM-yy'; Or in your markup: <ChartAreas> <asp:ChartArea Name='ChartArea1'> <AxisX IsLabelAutoFit='True' TitleForeColor='#ff0000'> <LabelStyle Format='dddd, dd-MM-yy' /> <MajorGrid Enabled ='False'...

Make uneven table layout

html,asp.net

You can solve this using the attribute colspan on the td tag: <table border = '1'> <tr> <td colspan='2'> Do you love peanuts? This is a very important question. </td> </tr> <tr> <td> Yes, I do. </td> <td> No, I don't. </td> </tr> </table> Check this link ...

add BR between text in dynamically created control

c#,asp.net

You need to use InnerHtml property HtmlGenericControl li = new HtmlGenericControl('li'); li.ID = 'liQuestions' + recordcount.ToString(); li.Attributes.Add('role', 'Presentation'); ULRouting.Controls.Add(li); HtmlGenericControl anchor = new HtmlGenericControl('a'); li.Attributes.Add('myCustomIDAtribute', recordcount.ToString()); anchor.InnerHtml = 'Test <br/> 12345'; li.Controls.Add(anchor); Or, like this: anchor.Controls.Add(new LiteralControl('Test')); //or new Literal('Test'); anchor.Controls.Add(new HtmlGenericControl('br'));...

Database object with different data

sql,asp.net,asp.net-mvc,database,entity-framework-6

Ideally what you want is a many-to-many relationship between your Shop and Product entities: public class Shop { public int ShopId {get; set;} public virtual ICollection<ShopProduct> ShopProducts {get; set;} } public class Product { public int ProductId {get; set;} public string Name {get; set;} public virtual ICollection<ShopProduct> ShopProducts {get; set;}...

Asp.Net Identity find users not in role

asp.net,linq,entity-framework,asp.net-identity

In c# you can get all users that are not in a certain role like this: var role = context.Roles.SingleOrDefault(m => m.Name 'role'); var usersNotInRole = context.Users.Where(m => m.Roles.All(r => r.RoleId != role.Id)); ...

check if file is image

c#,asp.net,asp.net-mvc

You can't do this: string.Contains(string array) Instead you have to rewrite that line of code to this: if (file null || formats.Any(f => file.Contains(f))) And this can be shortened down to: if (file null || formats.Any(file.Contains)) ...

WCF service architecture query

Authenticationtokencreatecontext Settoken

asp.net,architecture,wcfserviceclient

As long as you are able to use the exact same contract for all the versions the web application does not need to know which version of the WCF service it is accessing. In the configuration of the web application, you specify the URL and the contract. However, besides the...

Sending LIst via ajax to complex model

javascript,c#,asp.net,ajax

You don't need to JSON.stringify the recipients. 'recipients': JSON.stringify('[{'firstname':'a','lastname':'b','email':'c','voucheramount':'d'}]') Remove JSON.stringify form here and it should work. var postData = { 'workplaceGiverId': $('.wpgDropdownList').val(), 'fromMemberId': $('.wpgFromMemberDropdownList').val(), 'toMemberId': $('.wpgToMemberDropdownList').val(), 'voucherExpiryDate': $('#expiryDatePicker').val(), 'recipients': [{'firstname':'a','lastname':'b','email':'c','voucheramount':'d'}] }; ...

asp.net background in 3 pieces to be stationary

html,css,asp.net

I would use a separate div and use fixed positioning on it. Example <head> <meta http-equiv='Content-Type'> <title>Layout Example</title> <link type='text/css' href='./Layout Example_files/style.css'> <style type='text/css'> .fixed-background{ background: url( 'images/SoapBubbles.jpg' ) no-repeat fixed top center; position:fixed; z-index:-1; top:0; right:0; left:0; bottom:0; } </style> </head> <body> <div...

Callback on client does not get triggered with SignalR

javascript,c#,asp.net,signalr

It looks like you are missing client in: $hub.client.onRecieveNotification = function (message) { $('#message').append($('<li></li>', { text: message })); } ...

Show/hide tinymce with radio buttons

c#,asp.net,asp.net-mvc,tinymce

Your missing an @symbol for the id attribute: Modify your script as well like this: ***EDIT some thing seems off about the radio buttons only one should be checked and they should have the same name ** you can use the # to denote and ID in Jquery by the...

How IE setting affect authorization

asp.net,iis

If you set 'Enable Integrated Windows Authentication' (which is the default), and the server requires integrated Windows authentication, then the user will be authenticated silently using current default credentials, if possible. If you disable Integrated Windows Authentication, the user will be prompted to supply credentials. See this KB article for...

onSuccess and onFailure doesn't get fired

javascript,c#,asp.net,webmethod,pagemethods

You PageMethod is looking like this PageMethods.LoginUser(onSuccess, onFailure, email, pass); And when you call it, it looks like this PageMethods.LoginUser(email, pass); Your arguments should be in the same order as the method. PageMethods.LoginUser(email, pass, onSuccess, onFailure); ...

Unable to find the auto created Database

c#,asp.net,asp.net-mvc,entity-framework

If you don't specify a database name then the connection will use the default database for the user, in this case it's integrated security so it's your Windows login. As you likely have full system admin on the server the default database will be master so you will find all...

Creating a viewmodel on an existing project

c#,asp.net,asp.net-mvc

You are using a namespace, your full type name is Project.ViewModel.ViewModel (namespace is Project.ViewModel and class name is ViewModel) so use this using instead: @model Project.ViewModel.ViewModel ...

How to enable multiple login tries in asp.net forms authentication?

c#,asp.net,asp.net-mvc,authentication

It's because of your ViewBag's returnUrl sets null after postback, just simply put ViewBag.ReturnUrl = returnUrl; at the beginning of your HttpPost verb of Login action. ...

SQL Server / C# : Filter for System.Date - results only entries at 00:00:00

c#,asp.net,sql-server,date,gridview-sorting

What happens if you change all of the filters to use 'LIKE': if (DropDownList1.SelectedValue.ToString().Equals('Start')) { FilterExpression = string.Format('Start LIKE '{0}%', TextBox1.Text); } Then, you're not matching against an exact date (at midnight), but matching any date-times which start with that date. Update Or perhaps you could try this... if (DropDownList1.SelectedValue.ToString().Equals('Start'))...

Why is my View not displaying value of ViewBag?

c#,asp.net,asp.net-mvc,asp.net-mvc-4,razor

ViewBag is used when returning a view, not when redirecting to another action. Basically it doesn't persist across separate requests. Try using TempData instead: TempData['Tag'] = post.SelectedTag.ToString(); and in the view: <p><strong>Tag: @TempData['Tag']</strong></p> ...

Azure Mobile Services: migrate to non-Azure Windows Server

asp.net,azure,azure-mobile-services

It is entirely possible to move the .NET runtime - This is just an ASP.NET Web API site, and it can be hosted anywhere that you might run ASP.NET. However, some features such as the login functionality will not be available. For the Node.JS runtime, the actual process running the...

ASP.net website is not working properly while configuring in Internet Information Services

c#,asp.net,oracle11g,iis-7

I haven't personally worked with an Oracle database, but from your stack trace I see the following error: Attempt to load Oracle client libraries threw BadImageFormatException. This problem will occur when running in 64 bit mode with the 32 bit Oracle client components installed. Take a look at this similar...

Difference between application and module pipelines in Nancy?

c#,asp.net,nancy

The module- and application pipelines are explained in detail in the wiki. It's basically hooks which are executed before and after route execution on a global (application pipelines) and per-module basis. Here's an example: If a route is resolved to a module called FooModule, the pipelines will be invoked as...

Cant delete in database because of constraints

c#,sql,asp.net,oracle

Best way to do it is by using a stored proceed rather than a sql statement in C# code. You are getting error because the referenced records are still present in referenced table and are using cmd.ExecuteReader(); rather than cmd.ExecuteNonQuery();. So you need to delete records for DBS2_MOVIE WHERE MOVIE_ID...

Retrieve data from one table and insert into another table

sql,asp.net,sql-server

INSERT INTO tbl2 ( Name ,parentId ) SELECT DISTINCT manager ,0 FROM tbl1 WHERE manager NOT IN ( SELECT employee FROM tbl1 ) INSERT INTO tbl2 SELECT DISTINCT employee ,0 FROM tbl1 UPDATE tbl2 SET parentid = parent.id FROM tbl2 INNER JOIN tbl1 ON tbl2.Name = tbl1.employee INNER JOIN tbl2...

Event on dynamically created checkbox asp.net

c#,jquery,asp.net,table,checkbox

you can try this code List<CheckBox> lstChckBox; protected void Page_Load(object sender, EventArgs e) { // you can create controls programaticaly or html page, doesnt important //only you should know controls ID and all controls share same checked event CheckBox chc1 = new CheckBox(); chc1.CheckedChanged += new EventHandler(chck_CheckedChanged); CheckBox chc2 =...

Select @field From table as parameter

asp.net,sql-server,parameter-passing

If doing it from codebehind works then you can do something like sdsOrderErrors.SelectCommand = string.Format('SELECT {0} AS fld FROM [a_table]', colName); (OR) Have a stored procedure to accept a parameter and perform a dynamic query to achieve the same like create procedure usp_testSelect(@colname varchar(30)) as begin declare @sql varchar(200); set...

UpdatePanel AsyncPostbackTrigger not firing

asp.net,ajax,webforms,updatepanel

I have just tested your code and seems to be working with some test modifications: ASPX <asp:UpdatePanel runat='server' UpdateMode='Conditional'> <ContentTemplate> <asp:DropDownList runat='server' Width='250px' AutoPostback='true' OnSelectedIndexChanged='ddlSwitch_SelectedIndexChanged'> <asp:ListItem Value='continent' Text='Continent'></asp:ListItem> <asp:ListItem Value='region' Text='Region'></asp:ListItem> <asp:ListItem Value='country'...

How to change the colour and style of MajorGrid of AxisY in ASP.net chart

c#,asp.net,charts

May be this post will help you to change color of grid but keep AXIS same Visual Studio 2010 Chart control - line color. For line style Chart1.ChartAreas[0].AxisY.MajorGrid.LineDashStyle = System.Web.UI.DataVisualization.Charting.ChartDashStyle.Dash; ...

CommandName = Insert in EditTemplate of ASP.NET ListView throws “Insert can only be called on an insert item”

c#,asp.net,listview

Authenticationtokencreatecontext Serializeticket

The error is self explanatory. Take a look at this: https://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.listview.insertitemtemplate(v=vs.110).aspx So you can do either of these things. Create an InsertItemplate and insert using the ItemInserted event of the listview Change the CommandName to CommandName='InsertData' and catch that event on the ItemCommand ...

why does the compiler complain about missing ctor of WebSocketHandler?

protected member is accessible by derived class instances and there's nothing special about it. Nothing special in the class itself, either @ WebSocketHandler.cs. It just mens you need to pass in a nullable type, it does not mean it can't get any arguments. int? maxIncomingMessageSize = 0; var socket =...

ASP.NET httpHandlers & handlers

Authenticationtokencreatecontext

asp.net,asp.net-mvc

The system.webServer section in the Web.config file specifies settings for IIS 7.0 that are applied to the Web application. The system.WebServer is a child of the configuration section. For more information, see IIS 7.0: system.webServer Section Group (IIS Settings Schema). and <system.web> specifies the root element for the ASP.NET configuration...

Random Questions keep on repeating

c#,asp.net

Hi here the problem is with your random function. If you want to make sure one question will get repeated only after all the questions have shown atleast one. step 1: keep a array with length equal to the number of question. step 2: get a random question . step...

Gridview items not populating correctly

asp.net,vb.net

Try this vb code behind, then comment out my test Private Sub BindGrid() Dim dt_SQL_Results As New DataTable ' Commenting out to use test data as I have no access to your database 'Dim da As SqlClient.SqlDataAdapter 'Dim strSQL2 As String 'Dim Response As String = ' 'strSQL2 = 'SELECT...

Providing login_hint option for Google Oauth2 redirect

oauth,google-api,google-oauth

You should pass the variable to state. In the callback argument, you can parse your variable from state argument. For example, https://accounts.google.com/o/oauth2/auth?scope=email profile&state={'user_id': 1}&redirect_uri=http://localhost&response_type=code&client_id=xxxxxxxx.apps.googleusercontent.com&approval_prompt=force The callback url will be http://localhost/code?state={'user_id': 1}&code=4/P7q7W91a-oMsCeLvIaQm6bTrgtp7...

RequiredFieldValidator not working in my ASp site

c#,css,asp.net,twitter-bootstrap

You just miss a little thing i.e. to assign a Validation Group to your buttons and your RequiredFieldValidators. Your code should be: <div> <h2>Registration</h2> <p>Please fill out the forms to complete your registration.</p> <form> <div> <label for='username'>Name:</label> <asp:TextBox runat='server' CssClass='form-control' /> <asp:RequiredFieldValidator runat='server'...

Multiple Posted Types asp.net 5 MVC 6 API

c#,asp.net,asp.net-mvc,asp.net-5,asp.net-mvc-6

The best way is to create a composite wrapper: public class Wrapper { public ModelA A { get; set; } public ModelB B { get; set; } } Put Wrapper in the parameter list and mark that [FromBody]. You can't use that attribute more than once because all of the...

System.net.http.formatting causing issues with Newtonsoft.json

c#,asp.net,asp.net-mvc,json.net

Does the assemblyBinding tag have proper xmlns schema? Check if the issue you are encountering is same as Assembly binding redirect does not work

deployment of a site asp.net and iis

c#,asp.net,iis

There are several domain providers like: godaddy, name etc you can use to buy a domain name. These providers also provide you steps to map the domain name to your website. Check out this link for example. This link explains domain name configuration in details.

Problems With FOR XML AUTO

sql,asp.net,sql-server,subquery,sqlxml

Change XML PATH(') to XML PATH('tag')

Trigger a js function with parameter from code behind

Authenticationtokencreatecontext

c#,jquery,asp.net,scriptmanager,registerstartupscript

All you need to do is add a semi-colon to the end of your String.Format call. ScriptManager.RegisterStartupScript(this, this.GetType(), 'ScriptManager1', String.Format(@'ShowHideMessageBlock('{0}');', @'#successMsg'), true); ...

Third-party security providers like Google, Twitter etc. in ASP.Net

asp.net,authentication

No, you cannot enter any string. You will need to register with each provider to get the parameters that you need. See http://www.asp.net/web-api/overview/security/external-authentication-services for instructions on how to do this....