Using powershell to deploy provider-hosted app and specify remote Url instead of using appinv.aspx page

Hello all,
Could you possibly help me with provider-hosted app development/deployment process.
We developed SharePoint provider-hosted app that works just fine in development environment. Now we need to automate it's installation in test environment via powershell.
In AppManifest.xml that we are deploying we have key instead of explicit URL:
<App xmlns="http://schemas.microsoft.com/sharepoint/2012/app/manifest" Name="ShowAllRoomsApp" ProductID="{922a18aa-5592-b59a-4da9-4791baef02e7}" Version="1.0.0.0"
SharePointMinVersion="15.0.0.0">
  <Properties>
    <Title>SomeTitle</Title>
    <StartPage>~remoteAppUrl/Pages/Default.aspx?{StandardTokens}</StartPage>
If we use as
https://technet.microsoft.com/en-us/library/jj655398.aspx recommends, we cannot specify Redirect Url as we can do this on
/_layouts/appinv.aspx
So now it seems like the only way to deploy this kind of solution is using appinv.aspx page.Or must we apply this URL in AppManifest on developing stage in Visual Studio?
What did I miss?
P. S. Even if I use /_layouts/appinv.aspx after powershell commandlets, I get error.

hi,
to deploy provider hosted app you need 2 things
1. Client ID
2. Redirect URL.
What you can do you can generate app from visual studio using clientID and URL from developer enviornment.
Now a app file is just a simple compressed zip file if you rename it as .zip and extract you will find AppManifest
inside it. So to create an app for Testing enviornment what you have to to Get the CLient ID (from AppRegNew.aspx) in testing enviornment. Unzip .App file change the AppManifest with testing client ID and URL than again zip file and rename as .app.
Now if you upload this file it will work.
To automate this scenerio i have created a simple windows Application in which i Pass the Client ID and StartURl and an App File it unzips the app file make changes to app and again zip it.
public static class AppPackageHelper
public const string StartUrlExpression = "{0}?{1}";
public const string StandardToken = "{StandardTokens}";
public static string Publish(string appPath, string ClientId,string StartUrl)
string tempDir = string.Empty;
string outPutFile = string.Empty;
try
string parentDir = System.IO.Path.GetDirectoryName(appPath);
outPutFile = System.IO.Path.Combine(parentDir, ClientId + "-Winshuttle.app");
tempDir = System.IO.Path.Combine(parentDir, ClientId.ToString());
Directory.CreateDirectory(tempDir);
int lastInd = appPath.LastIndexOf('.');
string tempPath = string.Empty;
string targetFilePath = string.Empty;
string cabPath = System.IO.Path.Combine(tempDir, System.IO.Path.GetFileNameWithoutExtension(appPath) + ".cab");
FileInfo fInfo = new FileInfo(appPath) { IsReadOnly = false };
File.Copy(appPath, cabPath);
XDocument doc = null;
string appManifest = string.Empty;
using (ZipArchive zipArch = ZipFile.Open(cabPath, ZipArchiveMode.Update))
appManifest = string.Format(@"{0}\AppManifest.xml", Directory.GetParent(cabPath).FullName);
ZipArchiveEntry manifestEntry = zipArch.Entries.LastOrDefault(e => e.Name.ToLower() == "appmanifest.xml");
manifestEntry.ExtractToFile(appManifest);
doc = XDocument.Load(appManifest);
XNamespace ns = doc.Root.GetDefaultNamespace();
string defaultUrl = string.Format(StartUrlExpression, StartUrl.TrimEnd('/'), StandardToken);
doc.Descendants(XName.Get("StartPage", ns.NamespaceName)).First().Value = defaultUrl;
doc.Descendants(XName.Get("RemoteWebApplication", ns.NamespaceName)).First().Attribute(XName.Get("ClientId")).Value = setupInfo.ClientId.ToString();
doc.Save(appManifest);
if (manifestEntry != null)
manifestEntry.Delete();
zipArch.CreateEntryFromFile(appManifest, "AppManifest.xml");
int totEnt = zipArch.Entries.Count;
for (int e = 0; e < totEnt; e++)
if (zipArch.Entries[e].Open().Length == 0)
//if (zipArch.Entries.Count > totEnt && e >= totEnt) break;
//zipArch.CreateEntry(zipArch.Entries[e].FullName);
File.Delete(appManifest);
if (File.Exists(outPutFile))
File.Delete(outPutFile);
File.Move(cabPath, outPutFile);
return outPutFile;
catch
throw;
finally
if (System.IO.Directory.Exists(tempDir))
System.IO.Directory.Delete(tempDir, true);
return outPutFile;
using System.IO.Compression.FileSystem.dll.
Also if you want to do it using powershell You need to do the same thing unzip-> changes values-> zip
So basic thing is You need to ahve only valid AppManifest file which contains 2 valid values Client Id and StartUrl
if you changes it inside appmanifest manuall than it will also work. Using above code you can create a console Application to do it. You can use powershell it just that i dont know how to zip unzip in powershell but i am pretty sure you can easily find it
on searching.
Whenever you see a reply and if you think is helpful,Vote As Helpful! And whenever you see a reply being an answer to the question of the thread, click Mark As Answer

Similar Messages

  • Sharepoint provider hosted app using angularjs

    I am working on a provider hosted app and trying to access the list item through REST call using angularjs. But I am not able to access the list. Is it possible to access the sharepoint list through REST call using angularjs in a provider hosted app?
    Below is the code for angular:
    var hostWebApp = angular.module('HostWebList', []);
    Service:
    hostWebApp.service('$SharePointJSOMService', function ($q, $http) {
        this.getListItems = function ($scope, listTitle) {
            var deferred = $q.defer();
            //First we must call the EnsureSetup method
            JSRequest.EnsureSetup();
            var hostweburl = decodeURIComponent(JSRequest.QueryString["SPHostUrl"]);
            var appweburl = decodeURIComponent(JSRequest.QueryString["SPAppWebUrl"]);
            var restQueryUrl = hostweburl + "/_api/web/lists/getbytitle('ListName')/items";
            var executor = new SP.RequestExecutor(hostweburl);
            executor.executeAsync({
                url: restQueryUrl,
                method: "GET",
                headers: { "Accept": "application/json; odata=verbose" },
                success: function (data, textStatus, xhr) {
                    deferred.resolve(JSON.parse(data.body));
                error: function (xhr, textStatus, errorThrown) {
                    alert("request failed");
                    alert(textStatus);
    //getting -1003
                    alert(JSON.stringify(xhr));
    //{"responseAvailable":false,"body":,"Header":null}
                    deferred.reject(JSON.stringify(xhr));
            return deferred.promise;
    Controller:
    hostWebApp.controller('HostWebListController', function ($scope, $SharePointJSOMService) {
        $scope.listItem = null;
        var listName = "IncomingEmail";
        var promise = $SharePointJSOMService.getListItems($scope, listName);
        promise.then(function (data) {
            $scope.listItem = data.d.results;
            alert($scope.listItem);
            console.log("came inside the promise success method");
        }, function (data) {
            console.log("Error " + data);
    Following javascript files I have included:
     <script type="text/javascript" src="/_layouts/15/sp.runtime.js"></script>
      <script type="text/javascript" src="/_layouts/15/sp.js"></script>
     <script type="text/javascript" src="/_layouts/15/SP.RequestExecutor.js"></script>
     <script type="text/javascript" src="/_layouts/15/init.debug.js"></script>
    angular.js included. 
    I don't know what is the problem. Can anybody walk me through the problem. will be great help.

    Your REST request must be authenticated. So you must send the access token in the authorization header along with your request. The following link explains how you can get the access token when you using a provider hosted app.
    http://blog.mastykarz.nl/using-sharepoint-rest-api-in-provider-hosted-apps/
    Blog | SharePoint Field Notes Dev Tools |
    SPFastDeploy | SPRemoteAPIExplorer

  • How to get the current user name in Provider hosted app using appOnlyAccessToken

    Hi, 
    Please help me, how to get the HostWeb UserName in Provider Hosted App
    i have Provider hosted App, and Anonymous Authentication is enabled on AppWeb, using appOnlyAccessToken
    Below code does not return current user who Log in in hostweb, it is returning
    SharePoint App (app@sharepoint)
    Web web = clientContext.Web;
    clientContext.Load(web);
    clientContext.ExecuteQuery();
    clientContext.Load(web.CurrentUser);
    clientContext.ExecuteQuery();
    clientContext.Web.CurrentUser.LoginName;
    Below code gives a blank name when Anonymous Authentication is enabled, if Anonymous Authentication is disabled
    app prompts for credentials 
    HttpContext.Current.User.Identity.Name
    Thanks
    Ram

    Hi,
    Since you are using a provider Hosted app if you want to get the current logged in name than do not use AppOnlyAccessToken else use AccessToken which is App + user Context AccessToken.
    then 
    Web web = clientContext.Web;
    clientContext.Load(web);
    clientContext.ExecuteQuery();
    clientContext.Load(web.CurrentUser);
    clientContext.ExecuteQuery();
    clientContext.Web.CurrentUser.LoginName;will return proper user Name.
    HttpContext.Current.User.Identity.Name will never return the user as this object is related to IIS server of your App Server not sharepoint.you should set this as Anonymous in case of provider hosted app.you can download the below sample which uses the AccessToken which has user name in it.https://code.msdn.microsoft.com/Working-provider-hosted-8fdf2d95
    Whenever you see a reply and if you think is helpful,Vote As Helpful! And whenever you see a reply being an answer to the question of the thread, click Mark As Answer

  • Provider hosted app in windows Azure cloud Virtual Machine

    Hi
    thanks in advance,
    1. I am having requirement to setup a sitecollections specific to clients with same app installed for each client site collection( as app will act specific to client configuration).
    Thoughts :
    1. Create a provider hosted app or SharePoint hosted app and SharePoint site collections in the same virtual machine in Cloud.
     I am able to achieve high Trust provider hosted app on premise, it is working.
    Can any body suggest my thoughts on the approach is right or wrong. If wrong please suggest me how to achieve this.

    Hi,
    I have a sharepoint online site and Azure Virtual Machine.
    I have developed 4 SharePoint provider hosted apps and I want to deploy the same in office 0365 and App web should in Azure VM.
    So I seek help in terms with understanding the deployment.
    Because Azure comes with its own certificate cloudapp.net and what I find is this is a private certificate so I cannot use it outside.
    Please let me know if I am wrong, I need to buy a third party SSL certificate but doing so can I map it with cloudapp.net domain(which is provided by microsoft). Also Virtual machine is not in the domain. If so then do I also need a wild card certificate
    because I need to deploy 4 apps.
    just to conclude,
    I have SharePoint online site.
    Azure Virtual Machine (can I use the cloudapp.net certificate)
    SharePoint provider hosted apps(4 apps).
    Thanks and Regards Anup Kadam

  • Redirection error An error occurred while processing your request in provider-hosted app which is hosted in Windows Azure

    Hello,
    I developed one simple provider hosted app and I published it in my Azure website. I also published the SharePoint App of this solution in O365 site. I'm using Visual Studio 2013 Premium edition. I've followed all the steps to do this work e.g.
    generate the client ID and client secret through my O365 site and updated the AppManifest.xml as well as web.config etc. In my AppWeb project, I've TokenHelper.cs and SharePoint.cs classes.
    When I'm clicking the app from my O365 site, I get the following error "An error occurred while processing your request" which is due to the following code:
     protected void Page_PreInit(object sender, EventArgs e)
                Uri redirectUrl;
                switch (SharePointContextProvider.CheckRedirectionStatus(Context, out redirectUrl))
                    case RedirectionStatus.Ok:
                        return;
                    case RedirectionStatus.ShouldRedirect:
                        Response.Redirect(redirectUrl.AbsoluteUri, endResponse: true);
                        break;
                    case RedirectionStatus.CanNotRedirect:
                        Response.Write("An error occurred while processing your request.");
                        Response.End();
                        break;
    It's always executing the case RedirectionStatus.CanNotRedirect. Why?
    I've checked the method "CheckRedirectionStatus" of SharePointContext.cs class completely and I am not understanding why am I getting this error.
    When I browse my Azure website http://sitename.azurewebsites.net, even there I'm getting this error. I believe that error is because there is no query string parameter there e.g. SPHostURL etc.
    Please let me know why I'm having this redirection error.
    Thanks,
    Ashish

    Hi,
    For a better troubleshooting,
    I suggest you do as the following:
    Debug the code step by step to find the reason of the issue.
    For the remote debug your app from Windows Azure, you need to download Azure SDK:
    http://azure.microsoft.com/en-us/downloads/
    After installing the SDK, it will have “Attach Debugger” for Azure web site, you
    also need to set "Attach Debugger" to on in the Windows Azure Management Portal
    More detailed information about how to debug provider-hosted app:
    http://blogs.technet.com/b/speschka/archive/2013/11/25/debugging-sharepoint-apps-that-are-hosted-in-windows-azure-web-sites.aspx
    Best regards,
    ZhengyuGuo
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if
    they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Zhengyu Guo
    TechNet Community Support

  • Provider hosted app error message: The remote server returned an error: (429) Too Many Requests.

    Hi,
    I have a customer running a provider hosted app and in Sharepoint 2013. Things have been working fine but recently they keep experiencing an issue where the all the app parts on the page show the following error message. Does anyone have an idea what
    could be causing this problem and how I can fix it? The Sharepoint site and provider hosted app site are running on a Server 2008 R2 box with IIS 7.5.
    Server Error in '/Test.Sharepoint.App' Application.
    The remote server returned an error: (429) Too Many Requests.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.           
    Exception Details: System.Net.WebException: The remote server returned an error: (429) Too Many Requests.
    Source Error:
    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
    Stack Trace:
    [WebException: The remote server returned an error: (429) Too Many Requests.]
    System.Net.HttpWebRequest.GetResponse() +8527180
    Microsoft.SharePoint.Client.SPWebRequestExecutor.Execute() +58
    Microsoft.SharePoint.Client.ClientRequest.ExecuteQueryToServer(ChunkStringBuilder sb) +975
    Test.Sharepoint.AppWeb.Pages.LatestAnnouncement.GetLatestAnnouncement(Boolean showFullText) +610
    Test.Sharepoint.AppWeb.Pages.LatestAnnouncement.Page_Load(Object sender, EventArgs e) +764
    System.Web.UI.Control.LoadRecursive() +71
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3178
    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18034
    Impreza Software Development

    Hi GuYumming,
    I have checked the Sharepoint site using Fiddler and my X-SharePointHealthScore stays consistently on 1, I have even refreshed the site and had the "(429) Too Many Requests" error happen right in front of me whilst Fiddler is running and when I look at the
    200 response for the Sharepoint site it is still showing "X-SharePointHealthScore: 1".
    I assume because of this I do not need to make any of the changes suggested in your article above?
    I have also been through the ULS logs and found the following 3 log entries that appear to relate to the issue but they do not really mean much to me so I am hoping that you can help:
    Begin CSOM Request ManagedThreadId=59, NativeThreadId=12476
    SPResourceTally(ClientServiceRequestDuration) value 1 + 150425 > 150000
    ResourceBudgetExceeded, sending throttled status code. Exception=Microsoft.SharePoint.SPResourceBudgetExceededException: ResourceBudgetExceeded     at Microsoft.SharePoint.SPResourceTally.Check(Int32 value)    
    at Microsoft.SharePoint.SPAggregateResourceTally.Check(SPResourceKind kind, Int32 value)     at Microsoft.SharePoint.Client.SPClientServiceHost.OnBeginRequest()
    Impreza Software Development

  • Setting Like in High Trust Provider-Hosted App

    We are trying to set Like from our App Part in High Trust Provider-Hosted App and it is failing with the following error:
    Call: Microsoft.Office.Server.ReputationModel.Reputation.SetLike(clientrContext, ListId.ToString(), 1, true);
    Error: {"The assembly Microsoft.SharePoint.Portal.Proxy, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c does not support app authentication."}
    Anyone has experience with those? Any workarounds? Appreciate any help.
    Paul Shkurikhin blog.sharepointalist.com

    If you are doing a provider hosted app you must call back into the SharePoint server using CSOM. Microsoft.Office.Server.ReputationModel.Reputation exists in both
    Microsoft.Office.Server.UserProfiles.dll  and Microsoft.SharePoint.Client.UserProfiles.
    Make sure your application is only referencing Microsoft.SharePoint.Client.UserProfiles.
    Blog |SharePoint Field Notes Dev Tool |
    SPFastDeploy

  • Claims aware Provider Hosted Apps - The SecurityToken was not well formed

    Dear Friends,
    Please help me,
    I have Created a Provider hosted apps and converted Basic Provider Hosted Application into Claims Aware Provider Hosted Application in SharePoint 2013.
    I did all configuration based on ADFS implementation.
    The error we got is
    Server Error in '/' Application.
    ID4230: The SecurityToken was not well formed. Expecting element name 'SecurityContextToken', found 'SP'.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
    Exception Details: System.IdentityModel.Tokens.SecurityTokenException: ID4230: The SecurityToken was not well formed. Expecting element name 'SecurityContextToken', found 'SP'.
    Source Error:
    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
    Stack Trace:
    [SecurityTokenException: ID4230: The SecurityToken was not well formed. Expecting element name 'SecurityContextToken', found 'SP'.]
    System.IdentityModel.Tokens.SessionSecurityTokenHandler.ReadToken(XmlReader reader, SecurityTokenResolver tokenResolver) +1082000
    System.IdentityModel.Tokens.SessionSecurityTokenHandler.ReadToken(Byte[] token, SecurityTokenResolver tokenResolver) +100
    System.IdentityModel.Services.SessionAuthenticationModule.ReadSessionTokenFromCookie(Byte[] sessionCookie) +623
    System.IdentityModel.Services.SessionAuthenticationModule.TryReadSessionTokenFromCookie(SessionSecurityToken& sessionToken) +164
    System.IdentityModel.Services.SessionAuthenticationModule.OnAuthenticateRequest(Object sender, EventArgs eventArgs) +173
    System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +80
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +165
    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.19453 
    Regards
    Jenkins NS
    Thanks &amp; Regards Jenkins

    Dear Friends,
    Please help me,
    I have Created a Provider hosted apps and converted Basic Provider Hosted Application into Claims Aware Provider Hosted Application in SharePoint 2013.
    I did all configuration based on ADFS implementation.
    The error we got is
    Server Error in '/' Application.
    ID4230: The SecurityToken was not well formed. Expecting element name 'SecurityContextToken', found 'SP'.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
    Exception Details: System.IdentityModel.Tokens.SecurityTokenException: ID4230: The SecurityToken was not well formed. Expecting element name 'SecurityContextToken', found 'SP'.
    Source Error:
    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
    Stack Trace:
    [SecurityTokenException: ID4230: The SecurityToken was not well formed. Expecting element name 'SecurityContextToken', found 'SP'.]
    System.IdentityModel.Tokens.SessionSecurityTokenHandler.ReadToken(XmlReader reader, SecurityTokenResolver tokenResolver) +1082000
    System.IdentityModel.Tokens.SessionSecurityTokenHandler.ReadToken(Byte[] token, SecurityTokenResolver tokenResolver) +100
    System.IdentityModel.Services.SessionAuthenticationModule.ReadSessionTokenFromCookie(Byte[] sessionCookie) +623
    System.IdentityModel.Services.SessionAuthenticationModule.TryReadSessionTokenFromCookie(SessionSecurityToken& sessionToken) +164
    System.IdentityModel.Services.SessionAuthenticationModule.OnAuthenticateRequest(Object sender, EventArgs eventArgs) +173
    System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +80
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +165
    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.19453 
    Regards
    Jenkins NS
    Thanks &amp; Regards Jenkins

  • SharePoint Provided host app - The client webpart suddenly got removed

    I have SharePoint provided host app and it contains one client webpart. I have added that webpart one of the pages in site after deploying the app in site.
    Issue we are facing now:
    The client webpart suddenly got removed from the page and no one has modified the page to delete the webpart.
    And it is not listing in App parts while trying to add the webpart to page.
    Is there any way to trace this issue?
    Thanks,
    Surya 
    Thanks, Surya

    Hi Surya,
    Please try to restore page history per the article below:
    http://rules.ssw.com.au/ITAndNetworking/Rules-to-Better-Sharepoint-for-End-Users/Pages/VersionHistory.aspx
    If you need to dig out who changed it, you may check ULS log or audit log if you have audit feature enabled.
    Regards,
    Rebecca Tu
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • Provider hosted App certificates (.cer & .pfx)

    I have a implemented a provider hosted App inside the SharePoint 2013 server (the certificates .cer & .pfx  taken from the IIS of same server) and able to get the result. However I am not clear about taking the certificates in the multi server
    environment (SharePoint Server & IIS server for remote web app).
    can anyone please suggest from which server (Sharepoint Server or IIS server)  do I need to take the .cer & .pfx files to configure multi server environment ?
    Thanks

    Hi,
    According to your post, my understanding is that you want to create a provider hosted app and use NLB in premise environment.
    You need to use a different certificate on this ‘Listener’ web application.
    Configuring SharePoint 2013 Apps and Multiple Web Applications on SSL with a
    Single IP Address
    For more information, you can refer to:
    Aspiring Architect: Sharepoint 2013 - Avoiding Azure on Dev Box
    More TroubleShooting Tips for High Trust Apps on SharePoint 2013
    You need to ensure that all connections to the SharePoint servers are secure and encrypted
    Best Regards,
    Linda Li
    Linda Li
    TechNet Community Support

  • Provider hosted App Error: You do not have permission...

    Hi everyone,
    i'm using SharePoint online. I opened a provider hosted app and when I run this I get this error:
    "Access denied. You do not have permission to perform this action or access this resource."
    when I did debug I notice that it fall in this line:
    webRequestEventArgs.WebRequestExecutor.RequestHeaders["Authorization"]
    and "webRequestEventArgs.WebRequestExecutor.RequestHeaders"
    is empty.
    what can I do?
    thank you!

    i'm trying to add an item ti my list:
    protected void Page_Load(object sender, EventArgs e)
    //constant string SharePoint principal
    string SharePointPrincipal = "00000003-0000-0ff1-ce00-000000000000";
    var contextToken = TokenHelper.GetContextTokenFromRequest(Page.Request);
    Uri hostWeb = new Uri(Page.Request["SPHostUrl"]);
    string realm = TokenHelper.GetRealmFromTargetUrl(hostWeb);
    string appOnlyAccessToken = TokenHelper.GetAppOnlyAccessToken(SharePointPrincipal, hostWeb.Authority, realm).AccessToken;
    using (ClientContext clientContext = TokenHelper.GetClientContextWithAccessToken(hostWeb.ToString(), appOnlyAccessToken))
    if (clientContext != null)
    //ShariqTest is a custom List in my SharePoint site
    var myList = clientContext.Web.Lists.GetByTitle("ListName");
    ListItemCreationInformation listItemCreate = new ListItemCreationInformation();
    Microsoft.SharePoint.Client.ListItem newItem = myList.AddItem(listItemCreate);
    newItem["ColumnName"] = "Testing ";
    newItem.Update();
    clientContext.ExecuteQuery();
     "[and the  webRequestEventArgs.WebRequestExecutor.RequestHeaders["Authorization
    is in TokenHelper.cs.
    what do you think my problem is?

  • Provider Hosted App - Client Secret Expired

    We are using SharePoint Online with Provider Hosted app creates in ASP.NET. This portal gone live in December last year and was working fine till yesterday until we started facing the issues exactly after one year of portal going live. With this we have
    realized this has something to do with the ClientSecret token expiration issue because we have been getting the "JWT token invalid" issue. Further to this we have started following the below article and was able to generate the new ClientSecret and
    the same has been updated in Web.config file as well but still getting the same "JWT Token Invalid" error along with "Invalid Issuer or Signature" issue.
    http://msdn.microsoft.com/en-us/library/office/dn726681(v=office.15).aspx
    While above document suggest a method before ClientSecret being expired, but in our case we are trying to fight with the issue where our secret has been already expired. We have also waited for 12 hours after generating the fresh secret but nothing helps.
    Has anyone else experienced such situation, could someone please help me with this ?

    Thanks for replying John,
    This is SharePoint Online (E3 Plan) and the I issue has been resolved already. I have shared the resolution and finding for the same in "Apps for Office and SharePoint" forum at the URL below.
    https://social.msdn.microsoft.com/Forums/en-US/e5e5213a-68b3-4a1f-8809-7555a66b5782/provider-hosted-app-clientsecret-expired?forum=appsforsharepoint
    Thanks Again
    Ajay Sawant

  • Not able to debug Provider Hosted App in local (Deployed in Azure and Hosted in Office 365)

    I have Provider Hosted App - Deployed in Azure and Hosted in Office 365. 
    Deployed successfully on azure after attaching publishing profile of azure.
    Now I wish to debug app in local?

    Hi,
    According to your post, my understanding is that you want to debug SharePoint provider hosted app in local.
    Per the previous thread, to debug SharePoint provider hosted app in local, we should configure S2S authentication.
    You can follow the article below to build the high trust app, then you can debug the app locally.
    http://blog.karstein-consulting.com/2013/01/08/create-provider-hosted-high-trust-app-for-sharepoint-2013-short-guide/
    Thanks & Regards,
    Jason
    Jason Guo
    TechNet Community Support

  • Error occurred in deployment step 'Install app for SharePoint': Failed to install app for SharePoint. provider-hosted app sharepoint on premise

    Error occurred in deployment step 'Install app for SharePoint, ULS log as below:
    0x0BA8 SharePoint Foundation          App Deployment                 acjjg Medium   The current user has System.Threading.Thread.CurrentPrincipal.Identity.Name
    = 0#.w|perf\abraham.lincoln, System.Security.Principal.WindowsIdentity.GetCurrent().Name = NT AUTHORITY\IUSR, System.Web.HttpContext.Current.User.Identity.Name = 0#.w|perf\abraham.lincoln. dcf1d59c-94c5-5071-47bf-07cd3f2ead95
    12/14/2014 23:54:27.39  w3wp.exe (0x2170)                        0x0BA8 SharePoint Foundation        
     App Deployment                 ag8d6 Medium   SPApp: CreateAppUsingPackageMetadata: isCabStream is false. Treating the stream as a ZIP. dcf1d59c-94c5-5071-47bf-07cd3f2ead95
    12/14/2014 23:54:27.39  w3wp.exe (0x2170)                        0x0BA8 SharePoint Foundation        
     App Deployment                 ahkn9 High     Deleting App with fingerprint TJQrYuD5N+kEe38LZtl6wSs3Ak3yYvWcmwuNLTqtpdFzb4qSMopN3SWCRdWvntrKoM7qIS2S2llpA5omi8iHqQ==
    on site 264dc389-d394-4985-a43c-ad91a383c0df dcf1d59c-94c5-5071-47bf-07cd3f2ead95
    12/14/2014 23:54:27.39  w3wp.exe (0x2170)                        0x0BA8 SharePoint Foundation        
     App Deployment                 ahkob High     The App with fingerprint TJQrYuD5N+kEe38LZtl6wSs3Ak3yYvWcmwuNLTqtpdFzb4qSMopN3SWCRdWvntrKoM7qIS2S2llpA5omi8iHqQ==
    on site 264dc389-d394-4985-a43c-ad91a383c0df was to be deleted, but it did not exist dcf1d59c-94c5-5071-47bf-07cd3f2ead95
    12/14/2014 23:54:27.41  w3wp.exe (0x2170)                        0x0BA8 SharePoint Foundation        
     App Deployment                 abnqa Medium   App Packaging: CreatePackage: There are 10 parts in the package.  There are 1 package-part relationships
    in the package. dcf1d59c-94c5-5071-47bf-07cd3f2ead95
    12/14/2014 23:54:27.41  w3wp.exe (0x2170)                        0x0BA8 SharePoint Foundation        
     App Deployment                 afyz6 Medium   SPAppResources: ParseResources: No default resource file was found. dcf1d59c-94c5-5071-47bf-07cd3f2ead95
    12/14/2014 23:54:27.41  w3wp.exe (0x2170)                        0x0BA8 SharePoint Foundation        
     App Deployment                 afyzx Medium   SPAppResources: ParseResources: no resource file relationships were found. dcf1d59c-94c5-5071-47bf-07cd3f2ead95
    12/14/2014 23:54:27.41  w3wp.exe (0x2170)                        0x0BA8 SharePoint Foundation        
     App Deployment                 aebgs Medium   SPPackageUtility: ExtractPart: Creating directory 'C:\Users\abraham.lincoln.PERF\AppData\Local\Temp\71345ca6-3565-43d8-9017-2d3336965d8f\extract' dcf1d59c-94c5-5071-47bf-07cd3f2ead95
    12/14/2014 23:54:27.41  w3wp.exe (0x2170)                        0x0BA8 SharePoint Foundation        
     App Deployment                 aebgt Medium   SPPackageUtility: ExtractPart: Creating file 'C:\Users\abraham.lincoln.PERF\AppData\Local\Temp\71345ca6-3565-43d8-9017-2d3336965d8f\extract\AppManifest.xml' dcf1d59c-94c5-5071-47bf-07cd3f2ead95
    12/14/2014 23:54:27.41  w3wp.exe (0x2170)                        0x0BA8 SharePoint Foundation        
     App Deployment                 ajddw Medium   SPPackageUtility: ExtractPart: Part stream length is '1072'. dcf1d59c-94c5-5071-47bf-07cd3f2ead95
    12/14/2014 23:54:27.41  w3wp.exe (0x2170)                        0x0BA8 SharePoint Foundation        
     App Deployment                 ajddz Medium   SPPackageUtility: ExtractPart: Length is '1072', not locking before copying the stream. dcf1d59c-94c5-5071-47bf-07cd3f2ead95
    12/14/2014 23:54:27.41  w3wp.exe (0x2170)                        0x0BA8 SharePoint Foundation        
     App Deployment                 aebgt Medium   SPPackageUtility: ExtractPart: Creating file 'C:\Users\abraham.lincoln.PERF\AppData\Local\Temp\71345ca6-3565-43d8-9017-2d3336965d8f\extract\AppIcon.png' dcf1d59c-94c5-5071-47bf-07cd3f2ead95
    12/14/2014 23:54:27.41  w3wp.exe (0x2170)                        0x0BA8 SharePoint Foundation        
     App Deployment                 ajddw Medium   SPPackageUtility: ExtractPart: Part stream length is '3540'. dcf1d59c-94c5-5071-47bf-07cd3f2ead95
    12/14/2014 23:54:27.41  w3wp.exe (0x2170)                        0x0BA8 SharePoint Foundation        
     App Deployment                 ajddz Medium   SPPackageUtility: ExtractPart: Length is '3540', not locking before copying the stream. dcf1d59c-94c5-5071-47bf-07cd3f2ead95
    12/14/2014 23:54:27.41  w3wp.exe (0x2170)                        0x0BA8 SharePoint Foundation        
     App Deployment                 aidi7 Medium   SPIconAppPartValidator: IsSupportedFormat: image raw format is 'b96b3caf-0728-11d3-9d7b-0000f81ef32e'. dcf1d59c-94c5-5071-47bf-07cd3f2ead95
    12/14/2014 23:54:27.42  w3wp.exe (0x2170)                        0x0BA8 SharePoint Foundation        
     App Deployment                 afyz6 Medium   SPAppResources: ParseResources: No default resource file was found. dcf1d59c-94c5-5071-47bf-07cd3f2ead95
    12/14/2014 23:54:27.42  w3wp.exe (0x2170)                        0x0BA8 SharePoint Foundation        
     App Deployment                 afyzx Medium   SPAppResources: ParseResources: no resource file relationships were found. dcf1d59c-94c5-5071-47bf-07cd3f2ead95
    12/14/2014 23:54:27.42  w3wp.exe (0x2170)                        0x0BA8 SharePoint Foundation        
     App Deployment                 aebgt Medium   SPPackageUtility: ExtractPart: Creating file 'C:\Users\abraham.lincoln.PERF\AppData\Local\Temp\71345ca6-3565-43d8-9017-2d3336965d8f\extract\featurecc1deab7-efdf-4cc2-80ae-60e073577d64.xml' dcf1d59c-94c5-5071-47bf-07cd3f2ead95
    12/14/2014 23:54:27.42  w3wp.exe (0x2170)                        0x0BA8 SharePoint Foundation        
     App Deployment                 ajddw Medium   SPPackageUtility: ExtractPart: Part stream length is '321'. dcf1d59c-94c5-5071-47bf-07cd3f2ead95
    12/14/2014 23:54:27.42  w3wp.exe (0x2170)                        0x0BA8 SharePoint Foundation        
     App Deployment                 ajddz Medium   SPPackageUtility: ExtractPart: Length is '321', not locking before copying the stream. dcf1d59c-94c5-5071-47bf-07cd3f2ead95
    12/14/2014 23:54:27.42  w3wp.exe (0x2170)                        0x0BA8 SharePoint Foundation        
     App Deployment                 aebgt Medium   SPPackageUtility: ExtractPart: Creating file 'C:\Users\abraham.lincoln.PERF\AppData\Local\Temp\71345ca6-3565-43d8-9017-2d3336965d8f\extract\elements4d87f314-4b0a-4b89-8a7e-9cb73c99f25f.xml' dcf1d59c-94c5-5071-47bf-07cd3f2ead95
    12/14/2014 23:54:27.42  w3wp.exe (0x2170)                        0x0BA8 SharePoint Foundation        
     App Deployment                 ajddw Medium   SPPackageUtility: ExtractPart: Part stream length is '849'. dcf1d59c-94c5-5071-47bf-07cd3f2ead95
    12/14/2014 23:54:27.42  w3wp.exe (0x2170)                        0x0BA8 SharePoint Foundation        
     App Deployment                 ajddz Medium   SPPackageUtility: ExtractPart: Length is '849', not locking before copying the stream. dcf1d59c-94c5-5071-47bf-07cd3f2ead95
    12/14/2014 23:54:27.42  w3wp.exe (0x2170)                        0x0BA8 SharePoint Foundation        
     App Deployment                 aerhy Medium   App Packaging - List of App Parts (count ='2'): Name='SPIconAppPart',Name='SPFeatureAppPart', dcf1d59c-94c5-5071-47bf-07cd3f2ead95
    12/14/2014 23:54:27.42  w3wp.exe (0x2170)                        0x0BA8 SharePoint Foundation        
     App Deployment                 aerhz Medium   App Packaging - List of Deployment Groups (count ='3'): Name='SPIconDeploymentGroup',Name='SPTargetWebDeploymentGroup',Name='SPQuickLaunchDeploymentGroup', dcf1d59c-94c5-5071-47bf-07cd3f2ead95
    12/14/2014 23:54:27.42  w3wp.exe (0x2170)                        0x0BA8 SharePoint Foundation        
     App Deployment                 mq71 Medium   Creating App with fingerprint TJQrYuD5N+kEe38LZtl6wSs3Ak3yYvWcmwuNLTqtpdFzb4qSMopN3SWCRdWvntrKoM7qIS2S2llpA5omi8iHqQ==
    to site 264dc389-d394-4985-a43c-ad91a383c0df. dcf1d59c-94c5-5071-47bf-07cd3f2ead95
    12/14/2014 23:54:27.44  w3wp.exe (0x2170)                        0x0BA8 SharePoint Foundation        
     App Deployment                 afpd2 Medium   Committing package with fingerprint TJQrYuD5N+kEe38LZtl6wSs3Ak3yYvWcmwuNLTqtpdFzb4qSMopN3SWCRdWvntrKoM7qIS2S2llpA5omi8iHqQ==
    and data length 8010 to site 264dc389-d394-4985-a43c-ad91a383c0df. dcf1d59c-94c5-5071-47bf-07cd3f2ead95
    12/14/2014 23:54:27.46  w3wp.exe (0x2170)                        0x0BA8 SharePoint Foundation        
     App Deployment                 ajk9e Medium   Writing 8010 bytes to database for app with fingerprint TJQrYuD5N+kEe38LZtl6wSs3Ak3yYvWcmwuNLTqtpdFzb4qSMopN3SWCRdWvntrKoM7qIS2S2llpA5omi8iHqQ== dcf1d59c-94c5-5071-47bf-07cd3f2ead95
    12/14/2014 23:54:27.50  w3wp.exe (0x2170)

    Hi Jerry,
    I agree with Nikhil, I think you have posted partial ULS log, we could not find effective errors for the issue.
    For Provider Hosted app in SharePoint server on-premise,
    the TokenHelper class will try to access your Azure Security Principle by default.
    Did you have a valid Azure account?
    If not, the issue may be caused that you don't have a valid account, to resolve this issue, you can use
    a valid Azure account or not going to use Azure Platform for hosting the app as the article
    below.
    http://pratapreddypilaka.blogspot.jp/2012/12/sharepoint-2013-avoiding-azure-on-dev.html
    Thanks,
    Jason
    Jason Guo
    TechNet Community Support

  • The remote server returned an error :(401) unauthorized in Provider hosted app deployment

    Hi,
    We are trying to deploy the provider hosted app in server environment . we are getting the "The remote server returned an error :(401) unauthorized" error after deploy the app in server.
    stack Trace:
    [webException:Te remote server returned an error:(401) UnAuthorized.]
    System.Net.HeepWebRequest.GetResponse().
    Followed the same MSDN steps , but sill same error. We have attached the certificate and using the same issuer ID in the app web.config.
    Verified the IIS setting and still getting the same error when we call the "Clientcontext.ExecuteQuery()" method.
    Same code is working fine in my Local dev environment.
    If anyone have idea about this issue, please let me know.
    Thank you,
    Mylsamy

    Hi ,Thank you for your response. We have tried all the options and everything is same (Client ID,Issuer ID...etc) and finally figured out the issue.The below link saved my day.http://msdn.microsoft.com/en-us/library/office/dn762439(v=office.15).aspxIn "TokenHelper.cs" GetRealmFromTargetUrl method always return null andWhen we analyze the issue we found some variable name assigned for "Realm" Instead of GUID in SP server.Power shell command to get the Realm in SP server:  Get-SPAuthenticationRealmWe have followed below article to generate the new GUID for realm.http://technet.microsoft.com/en-us/library/jj219756(v=office.15).aspx$c =Get-SPServiceContext -Site "http://<websiteurl>"Set-SPAuthenticationRealm -ServiceContext $c -Realm "a686d436-9f16-42db-09b7-cb578e110ccd".
    Thankyou,Mylsamy

Maybe you are looking for