OAuth with RPCs

While using oauth

  1. Non-whitelisted APIs are not permitted.
  2. frappe.session.user = Guest

while it works for /api/resource/DocType.

def ping():
	authorization_header = frappe.get_request_header("Authorization").split(" ") if frappe.get_request_header("Authorization") else None
	if authorization_header and authorization_header[0].lower() == "bearer":
		from frappe.oauth import get_url_delimiter
		from frappe.integrations.oauth2 import get_oauth_server
		token = authorization_header[1]
		print frappe.db.get_value("OAuth Bearer Token", token, "user")
	return { 'user': frappe.session.user, 'oauth_user':frappe.db.get_value("OAuth Bearer Token", token, "user")}# response = {"user":"Guest", "oauth_user":"<Actual User ID>"}

Is this expected behaviour?

This is expected behaviour