#NEWLINE# @ oauth2_provider . grantsetter #NEWLINE# def set_grant( client_id , code , _request , * args , **kwargs ) : #NEWLINE# #INDENT# expires = ( datetime . utcnow ( ) + timedelta ( seconds = 100 ) ) #NEWLINE# grant = OAuth2AuthCode ( local . model , client_id = client_id , code = code [ 'code' ] , redirect_uri = _request . redirect_uri , scopes = ',' . join ( _request . scopes ) , user_id = request . user . user_id , expires = expires ) #NEWLINE# return local . model . save_oauth2_auth_code ( grant )