I tried below github sample for Azure AD Authentication and successfully getting access token with proper call back URL.
https://github.com/Microsoft/BotBuilder-Samples/tree/master/samples/csharp_dotnetcore/18.bot-authentication
Modified and Configured Web.config Keys as per my application created in https://apps.dev.microsoft.com
<add key="ActiveDirectory.Mode" value="v1" />
<add key="ActiveDirectory.ResourceId" value="https://graph.microsoft.com" />
<add key="ActiveDirectory.EndpointUrl" value="https://login.microsoftonline.com" />
<add key="ActiveDirectory.Tenant" value="xyz-xyz" />
<add key="ActiveDirectory.ClientId" value="xyz-xyz" />
<add key="ActiveDirectory.ClientSecret" value="xyz-xyz" />
<add key="ActiveDirectory.RedirectUrl" value="http://localhost:3979/api/Callback" />
<add key="ActiveDirectory.Scopes" value="Calendars.Read,Calendars.ReadWrite,Contacts.Read,Contacts.ReadWrite,Mail.Read,Mail.ReadWrite,User.Read" />
I had crossed checked access token that i received jwt.ms. It is a valid token with scopes defined exactly as i defined in web.config.
I am able to get User Profile data from API by passing token but while trying to call "Contacts" of user, I am getting below error.
{
"error": {
"code": "ResourceNotFound",
"message": "Resource could not be discovered.",
"innerError": {
"request-id": "6f0f3ec9-76c9-4662-ac25-0bc73f887268",
"date": "2019-03-02T17:23:35"
}
}
}
Code calling Contact API call.
//Get Logged in user contacts
public async Task<IUserContactsCollectionPage> GetMyContactsAsync()
{
var graphClient = GetAuthenticatedClient();
IUserContactsCollectionPage contacts = await graphClient.Me.Contacts.Request().GetAsync();
return contacts;
}
FYI: Displayed Sign In card in emulator Authorize sample URL is like below
https://login.microsoftonline.com/a76b43b0-3088-4c56-ba0d-01f317b1f18c/oauth2/authorize?resource=https:%2F%2Fgraph.microsoft.com&client_id=XYZ&response_type=code&haschrome=1&redirect_uri=http:%2F%2Flocalhost:3979%2Fapi%2FCallback&x-client-SKU=PCL.Desktop&x-client-Ver=3.13.9.1126&x-client-CPU=x64&x-client-OS=Microsoft+Windows+NT+10.0.16299.0&state=<stateID>
It might happens for many reason one of the very common issue is to required grant permission to your registered app. Make sure you have done following steps accordingly.
Step 1:
Login in to your portal and select your application under app registrations.
Then click on settings see the screen shot below:
Step 2:
Once you clicked Settings new window will come up right side, click on Required Permission menu: see the screen shot below:
Step 3:
Select Required Permission Menu and assign your permission by clicking on Add button
see the snap below:
Step 4:
Click on Select an API option see below:
Final Step:
Select your desired API and checked it which you are like to access for. Once finished the permission click on Done. After this step you can access your required resource / Scope from your application. Hope it will be helpful for you.Thank You.
see the screen shot below:
Related
I cannot manage to see a contextual gadget in Gmail after Test Install Flow in Google Apps Marketplace SDK.
These are the steps I took to create the project, logged as a domain administrator:
create Google Apps console project
create OAuth2 client
enable GAM SDK
configure the SDK page with COB extension:
Extractor Url: google.com:HelloWorld
GadgetUrl: URL of gadget spec
Extractor param name: Test
Extractor param value: .*
Scopes: Mail - Subject Line, Mail - Message Body
I didn't add any additional Oauth2 scopes than the userinfo.email and userinfo.profile that are already there, and the Universal Navigation link is just a file that redirects to Gmail( since I am trying a very simple variant of the project to see if I can get it to work ).
I press Test Install flow, I am asked to give permissions in a Oauth combined window, I am redirected to my Universal navigation link, then Gmail. The app appears in the Google Apps Admin control panel and seems to have installed successfully, it is ON for all domain users.
I tried Gmail with different domain users, cleared cache, logged out and back in to Gmail, I am probably missing a configuration somewhere.
This is the gadget spec:
<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs title="Title" description="Desc" author="" author_email="" author_location="" scrolling="false" height="20">
<Require feature="dynamic-height"/>
<Require feature="google.contentmatch">
<Param name="extractors">
google.com:HelloWorld
</Param>
</Require>
</ModulePrefs>
<Content type="html" view="card">
<![CDATA[
<script type="text/javascript">
<!-- Fetch the array of content matches. -->
matches = google.contentmatch.getContentMatches();
var matchList = document.createElement('UL');
var listItem;
var extractedText;
for (var match in matches) {
for (var key in matches[match]) {
listItem = document.createElement('LI');
extractedText = document.createTextNode(key + ": " + matches[match][key]);
listItem.appendChild(extractedText); matchList.appendChild(listItem); }
}
document.body.appendChild(matchList);
gadgets.window.adjustHeight(100);
</script>
]]>
</Content>
</Module>
Couple of suggestions -
Use the nocache option to force your Gmail UI to update. Use this link - https://mail.google.com/mail/u/0/?nogadgetcache=1#inbox
Try as a different account on the domain. I've seen some cases where the "developer/admin" inbox takes time to update
I'm trying to set up a custom Maintenance page on MVC 3 but specifically on Azure. Basically to keep it SEO friendly i need to return a 503 (Service Unavailable). All my other custom error pages work in Azure (eg 404) following the usual
<customErrors mode="On">
<error statusCode="404" redirect="404.htm"/>
<error statusCode="503" redirect="503.htm"/>
</customErrors>
The 404 page works but the 503 is not followed and i simply get an ugly service unavailable page. I have the 500 error working fine through error.cshtml and the standard HandleErrorAttribute.
I even try returning my own ActionResult from an ActionFilter by using the following
public class SiteDownForTestingResult : ActionResult
{
public SiteDownForTestingResult() : base()
{
}
public override void ExecuteResult(ControllerContext context)
{
var path = System.Web.Hosting.HostingEnvironment.MapPath("~/app_testing.htm");
var response = context.HttpContext.Response;
response.Clear();
response.StatusCode = (int)HttpStatusCode.ServiceUnavailable;
response.StatusDescription = "Service Unavailable.";
response.WriteFile(path);
response.End();
}
}
were app_testing is my custom page, and then setting the filterContext.Result = new SiteDownForTestingResult(); from OnActionExecuting of an ActionFilter and still i'm greeted by the plain 503 'service unavailable' page
Is this something to do with application.config on Azure locking something or other i don't know about. This works fine on IIS7 and my local box, but the Emulator and Cloud both give no joy.
Any help would be appreciated.
Based on my understanding custom 503 error is generated directly from https.sys mostly when app pool is not available. And now when there is no app pool none of your setting is going to work at your custom error settings will be specific to app pool. Also most of the search engine depend on 503 error code in return so display search result properly and that's why customization of this error is not typically done at application level.
As you referenced Windows Azure Emulator, I believe you are using Windows Azure Web Role. With Windows Azure Web Role you can customize IIS with AppCmd.exe in a StartUp task, which is your maximum level of customization. You can not reach HTTP.sys level of customization in Windows Azure so customization 503 error may not work on Windows Azure.
I have submited a App but is not certified because this:
"This application uses the Location Service API to determine a user's location and show them events taking place nearby
however, it does not appear to contain a privacy policy that is accessible to users explaining how the application uses the
Location Service API."
And what i want to do is something like this
When user clicks in Policty Statement open a new window with settings page with my app location policies.
Can anyone help me? How can i add a link like in image?
Cumps
You can navigate to a page using the Hyperlink control
<Textblock>
<Hyperlink NavigateUri="/PrivacyPage.xaml"
TargetName="_blank">Privacy Statement</Hyperlink>
</Textblock>
See MSDN for more info
I don't think you can put a hyperlink in a call to MessageBox.Show() though so you have to create your own Messagebox-like page.
The first time the app is launched you direct the user to your message page. E.g. using this in MainPage.xaml
OnNavigatedTo(...)
{
if(!AppSettings.HasMessageBeenShown)
{
AppSettings.HasMessageBeenShown=true;
NavigationContext.Navigate(new Uri("/MessagePage.xaml", UriKind.Relative));
}
}
I successfully deploy my custom Action to the list of Actions available for use in my SharePoint Designer, but when opening an existing workflow, or creating a new one in the Designer, I get the message (and of course my custom action is not on the list of actions)
The list of workflow actions on the server references an assembly that
does not exist. Some actions will not be available. The assembly
strong name is {Actual Assembly strong name}. Contact your server
administrator for more information.
I checked the Strong Assembly name, Global Assembly Cache, package options, .ACTIONS file, web.config... Everything seems ok. Any new Ideas?
I am assuming the custom action is a farm deployed activity, which inherits from System.Workflow.ComponentModel.Activity (perhaps using subclass SequenceActivity, but really that doesn't matter)
I'm guessing that you haven't created the required ACTIONS file, which gets deployed to TEMPLATE\1033\Workflow
<?xml version="1.0" encoding="utf-8" ?>
<WorkflowInfo>
<Actions Sequential="then" Parallel="and">
<Action Name="Description for SP Designer"
Assembly="$SharePoint.Project.AssemblyFullName$"
ClassName="AssemblyName.ClassName"
AppliesTo="all"
Category="SPD category"
UsesCurrentItem="true"
>
<RuleDesigner Sentence="Line as it appears in SPD workflow" />
<Parameters>
<Parameter Name="__ActivationProperties" Type="Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties, Microsoft.SharePoint" Direction="In" />
</Parameters>
</Action>
</Actions>
</WorkflowInfo>
SPD reads the list of activities from the ACTIONS files. Adding the file will get it into the menu. To actually add it to the workflow, you also need to authorize the custom workflow activity by class name.
To add the authorized type, I use a feature receiver with the following spwebmodification:
private SPWebConfigModification CreateWebConfigModification(string assembly, string assemblyNamespace)
{
return new SPWebConfigModification()
{
Type = (SPWebConfigModification.SPWebConfigModificationType)0,
Name = String.Format("authorizedType[#Assembly='{0}'][#Namespace='{1}'][#TypeName='*'][#Authorized='True']", (object)assembly, (object)assemblyNamespace),
Path = "configuration/System.Workflow.ComponentModel.WorkflowCompiler/authorizedTypes",
Owner = assemblyNamespace,
Sequence = 0U,
Value = String.Format("<authorizedType Assembly='{0}' Namespace='{1}' TypeName='*' Authorized='True' />", (object)assembly, (object)assemblyNamespace)
};
}
this will generate an SPWebConfigModification which can be used during install/uninstall.
Check you local admin privleges. This error comes up if you don't have local priveleges
create a new web and site collection and create a new a new workflow for the new site. you'll get the error message. don't save the work flow. and close the SPD.
reopen the designer and create a new work flow it'll solve the problem.
Can someone please post a confirmed example using linq to retrieve and update a record in CRM Dynamics 2011.
Microsoft claims this is "unsupported" but I have a suspicion it is possible.
I use the "early bound" approach where you generate C# entity classes using the CrmSvcUtil.exe tool, but make sure you use the /codecustomization switch that you'll find in various examples. You'll need the latest version of the CRM 2011 SDK, and must run CrmSvcUtil.exe from the \bin folder of that (don't use the version that installs with CRM).
Your project will need to reference Microsoft.Xrm.Client, Microsoft.Xrm.Sdk and Microsoft.Crm.Sdk.Proxy plus a few others from the .Net framework (look at the build errors to see what you're missing, then add them until it builds).
Here is a basic code snippet that retrieves a Contact entity, updates one of its fields, then saves it back to CRM:
CrmDataContext dc = new CrmDataContext("Xrm");
Contact contact = (from c in dc.ContactSet
where ...whatever...
select c).FirstOrDefault();
contact.FirstName = "Jo";
dc.SaveChanges();
(Note that CrmDataContext is the name of my data context. You can set this name using one of the CrmSvcUtil command line switches).
You'll also need to add a few things to your web.config:
<configSections>
<section name="microsoft.xrm.client" type="Microsoft.Xrm.Client.Configuration.CrmSection, Microsoft.Xrm.Client" />
</configSections>
<connectionStrings>
<add name="Xrm" connectionString="Server=http://<your crm url>; Domain=<your domain>; Username=<a crm user id>; Password=<their password>" />
</connectionStrings>
<microsoft.xrm.client>
<contexts>
<add name="Xrm" type="" />
</contexts>
</microsoft.xrm.client>
This is assuming you are running CRM on your corporate network, so the account and domain specified in the connection string would be an AD account, who is set up as a CRM user with relevant permissions to retrieve and update entities.
This is a rough example of using the ODATA provider connected to the online provider
var serverConfig = GetServerConfig(sessionKey);
// Connect to the Organization service.
// The using statement ensures that the service proxy will be properly disposed.
using (var serviceProxy = new OrganizationServiceProxy(serverConfig.OrganizationUri, serverConfig.HomeRealmUri, serverConfig.Credentials, serverConfig.DeviceCredentials))
{
// This statement is required to enable early-bound type support.
serviceProxy.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior());
using (var orgContext = new CrmServiceContext(serviceProxy))
{
return orgContext.AccountSet.Where(item => item.Id == id).Select().Single();
}
}
there's also a good example in the SDK:
CRM2011Sdk\sdk\samplecode\cs\wsdlbasedproxies\online