Get author_id in wordpress

Check the value in the get_query_var() function. An example, that works:–

$author = get_user_by( 'slug', get_query_var( 'author_name' ) );
echo $author->ID;

If you like only the author of post, inside the loop, then use the template tag get_the_author().