Recently I was working on CRM Dynamics migration where the system was upgraded to the latest version for CRM Dynamics Online. CRM should be using claims based authentication as I was trying to authenticate against my Office 365 account.
I had latest 2015 SDK and trying to utilize early bound approach to integrate in-house applications to CRM Dynamics Online.
Things were okay until I found that the application was throwing an error while saving the context. Ironically, the application was able to generate service proxy with provided Id and Password. It was failing only when I tried saving the context.
I started looking around in SDK where there are many samples given. I figured that unless I specify correct Device credentials the system continued rejecting the request due authentication error mentioned above.
I put in the following code to generate proxy by referring SDK
IServiceManagement<IOrganizationService> orgServiceManagement =
var clientCredentials = crmConnection.ClientCredentials;
var authCredentials = new AuthenticationCredentials();
authCredentials.ClientCredentials = clientCredentials;
authCredentials.SupportingCredentials = new AuthenticationCredentials();
authCredentials.SupportingCredentials.ClientCredentials = Microsoft.Crm.Services.Utility.DeviceIdManager.LoadOrRegisterDevice();
AuthenticationCredentials tokenCredentials = orgServiceManagement.Authenticate(authCredentials);
var organizationTokenResponse =
return proxy = new OrganizationServiceProxy(orgServiceManagement, organizationTokenResponse);
It should be noted that this code base should use the connection string specified in "developer resource" tab available when you log in to your CRM account.
If you have set up something similar mentioned above and facing similar issues then you should try using device credentials.