def METHOD_NAME(self, token, request, *args, **kwargs):
    db = OAuthBearerToken.dbsession
    if 'refresh_token' in request.body:
        bearer_token = self._get_bearer(refresh_token=request.body['refresh_token'])
    else:
        bearer_token = OAuthBearerToken(
            clientid=request.client_id,
            userid=request.userid,
            scopes=request.scopes,
        )
        db.add(bearer_token)
    bearer_token.access_token = token['access_token']
    bearer_token.refresh_token = token['refresh_token']
    bearer_token.expires_at = arrow.utcnow().replace(seconds=token['expires_in'])
    db.flush()