Microsoft.Health.HealthServiceAccessDeniedException: The authentication token element of the request is required for this method.

Answered Microsoft.Health.HealthServiceAccessDeniedException: The authentication token element of the request is required for this method.

  • Monday, December 03, 2012 12:51 PM
     
     

    when i call the function "SendInsecureMessageFromApplication" i get this error on localhost

    The authentication token element of the request is required for this method.

    i just want to send the current user the email, but could not send it due to this error.

    as i have a live application and a local for testing.  such thing before i deploy to live server.

    but on live it does not give me any error, but i also dont get any email in the client email address.

    can some on help. also dont get client email by this as well.

    The account-holder's email can be retrieved by an application by calling PersonInfo.GetSelfRecord() and then looking for the PersonalContactInfo singleton object.  The record-holder's email is in the record at PersonInfo.SelectedRecord.


    • Edited by ali farooq1 Monday, December 03, 2012 12:52 PM forgot the function name
    •  

All Replies

  • Monday, December 03, 2012 7:40 PM
     
     Answered Has Code

    Hi Ali,

    I assume you have already checked the settings in ACC that the application requires access to send e-mail through the platform (in the Methods tab).

    Please note that the email address someone wants to use associated with their Health Record may be different than the one associated with their Live ID or Open ID.  There is an email field stored inside the health record that is considered content, and can be read and used by apps. This could be empty.

    The email associated with the authentication credentials to access HealthVault is not content, and will not be shared.

    You can send mail to either of these accounts if you have proper permissions.

    To send mail to the person ID, you may use:

    Guid emailGuid = PersonInfo.PersonId;
    IList<Guid> recepient = new List<Guid>();
    recepient.Add(emailGuid);
    ApplicationConnection.SendInsecureMessageFromApplication(recepient, <rest of the arguments go here>) ;

    To send mail to the ID in the email field stored in the record, you may use:

    Contact contact = GetSingleValue<Contact>(Contact.TypeId);
    MailRecipient mailrecepient = new MailRecipient(contact.ContactInformation.Email[0].Address.ToString(), "<Display Value>");
    IList<MailRecipient> recepient2 = new List<MailRecipient>();
    recepient2.Add(mailrecepient);
    ApplicationConnection.SendInsecureMessageFromApplication(recepient2, <rest of the arguments go here>) ;

    (GetSingleValue implementation is available here.)


    • Edited by Santhosh Pillai Tuesday, December 04, 2012 4:53 AM
    • Marked As Answer by ali farooq1 Tuesday, December 04, 2012 8:40 AM
    •