function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ms-hase-q23eems-hase-q23ee 

RESTContext内でログインしたユーザーを特定するには?

お世話になっております。

掲題のとおりRESTインターフェイス(GETメソッドのロジックを想定しています)で接続されているユーザー情報を特定するにはどうすればいいのか、ご存知の方はいらっしゃいますでしょうか?

RestContext/RestRequestのどこを見ても分かりませんでした。OAuthで認証されているからにはどこかに存在するはずなのですが・・・こちらが見当たらない場合、開発者ガイドの例にあるように、[REST_url]/service_name/id=xxxxxの形で、呼び出し側にメールアドレス形式のログインIDを再度渡してもらわなければならないのですが、これだとURLから接続者が丸見えでhttps接続にも関わらず盗聴が容易になってしまいます。

ご存知の方は教えてください。
宜しくお願いいたします。

 
Best Answer chosen by ms-hase-q23ee
Taiki YoshikawaTaiki Yoshikawa
ちょっと自分では試したことが無いのですが、次の方法で取得できたりしないでしょうか。
(検索したところ次のやり方をしている方がいました。)
String userID = RestContext.request.params.get('userID');

もしかすると何か参考になるかもしれないサイトがいくつかあったのでリンクを共有します。

[Salesforce]apex Rest APIでPOSTでデータを送信する
http://kayamemo.mrlittlebig.com/blog/2014/10/27/apex-rest-post/

Apex RestService parameter not passing over
http://salesforce.stackexchange.com/questions/11764/apex-restservice-parameter-not-passing-over

Test code Apex Rest API-Urgent
https://developer.salesforce.com/forums?id=906F00000009AYzIAM

Salesforce REST Webservices - Part I
http://blogforce9.blogspot.jp/2013/09/salesforce-rest-webservices-part-i.html

All Answers

Taiki YoshikawaTaiki Yoshikawa
ちょっと自分では試したことが無いのですが、次の方法で取得できたりしないでしょうか。
(検索したところ次のやり方をしている方がいました。)
String userID = RestContext.request.params.get('userID');

もしかすると何か参考になるかもしれないサイトがいくつかあったのでリンクを共有します。

[Salesforce]apex Rest APIでPOSTでデータを送信する
http://kayamemo.mrlittlebig.com/blog/2014/10/27/apex-rest-post/

Apex RestService parameter not passing over
http://salesforce.stackexchange.com/questions/11764/apex-restservice-parameter-not-passing-over

Test code Apex Rest API-Urgent
https://developer.salesforce.com/forums?id=906F00000009AYzIAM

Salesforce REST Webservices - Part I
http://blogforce9.blogspot.jp/2013/09/salesforce-rest-webservices-part-i.html
This was selected as the best answer
ms-hase-q23eems-hase-q23ee
返信ありがとうございます。
この件は私がApexの世界をよく分かっていませんでした。

http://salesforce.stackexchange.com/questions/11764/apex-restservice-parameter-not-passing-over

UserInfoオブジェクトで取得できるのですね。Userオブジェクトから取ろうとして見れなかったので、無理なのかと思ってしまいました。

UserInfo.getUserName()
UserInfo.getId()
UserInfo.getLastName()
UserInfo.getFirstName()

で無事に取得できました。