amazon-archives / aws-sdk-xamarin

AWS Mobile SDK for Xamarin (Beta)
Apache License 2.0
45 stars 18 forks source link

Unable to find credentials when using DynamoDB Local #3

Closed Steven-Mark-Ford closed 9 years ago

Steven-Mark-Ford commented 10 years ago

I am have a local running instance of DynamoDB on port 8000 (as per http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Tools.DynamoDBLocal.html)

When I execute the following line of code: var client = new AmazonDynamoDBClient(new AmazonDynamoDBConfig(){ ServiceURL = "http://localhost:8000"});

I get the following exception: Amazon.Runtime.AmazonServiceException: Unable to find credentials Exception 1 of 1: Amazon.Runtime.AmazonServiceException: Unable to reach credentials server at Amazon.Runtime.InstanceProfileAWSCredentials.GetContents (System.Uri uri) [0x0004d] in f:\Tara\Code Files\AWS.XamarinSDK\AWSSDK_Android\Amazon.Runtime\AWSCredentials.cs:851 at Amazon.Runtime.InstanceProfileAWSCredentials+d__0.MoveNext () [0x00025] in f:\Tara\Code Files\AWS.XamarinSDK\AWSSDK_Android\Amazon.Runtime\AWSCredentials.cs:730 at Amazon.Runtime.InstanceProfileAWSCredentials.GetFirstRole () [0x0001a] in f:\Tara\Code Files\AWS.XamarinSDK\AWSSDK_Android\Amazon.Runtime\AWSCredentials.cs:858 at Amazon.Runtime.InstanceProfileAWSCredentials..ctor () [0x00000] in f:\Tara\Code Files\AWS.XamarinSDK\AWSSDK_Android\Amazon.Runtime\AWSCredentials.cs:716 at Amazon.Runtime.FallbackCredentialsFactory.b__1 () [0x00000] in f:\Tara\Code Files\AWS.XamarinSDK\AWSSDK_Android\Amazon.Runtime\AWSCredentials.cs:971 at Amazon.Runtime.FallbackCredentialsFactory.GetCredentials (Boolean fallbackToAnonymous) [0x00029] in f:\Tara\Code Files\AWS.XamarinSDK\AWSSDK_Android\Amazon.Runtime\AWSCredentials.cs:987 at Amazon.Runtime.FallbackCredentialsFactory.GetCredentials (Boolean fallbackToAnonymous) [0x000e6] in f:\Tara\Code Files\AWS.XamarinSDK\AWSSDK_Android\Amazon.Runtime\AWSCredentials.cs:1018 at Amazon.DynamoDBv2.AmazonDynamoDBClient..ctor (Amazon.DynamoDBv2.AmazonDynamoDBConfig config) [0x00000] in f:\Tara\Code Files\AWS.XamarinSDK\AWSSDK_Android\Amazon.DynamoDBv2\AmazonDynamoDBClient.cs:254

tawalke commented 10 years ago

Hi Steven:

Do you have the default credentials created in the SDK Store either via a profile in Visual Studio and/or in your app.config? In using the default constructors without declaring credentials, the credentials are pulled from the default credentials located there (SDK Store). Will you please review and advise so that I can narrow down your issue.

Please see documentation here for .NET with AWS: http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/TestingDotNetApiSamples.html

Steven-Mark-Ford commented 10 years ago

I do not have the default credentials created in the SDK Store. I am currently using Xamarin Studio.

tawalke commented 10 years ago

Hi Steven:

In using AWS for .NET with or without Visual Studio, you can store default credentials in the SDK store via the app.config, Powershell w/command line, or via file.

The steps outlined in creating or storing default credentials and the various options are here: http://docs.aws.amazon.com/AWSSdkDocsNET/latest/DeveloperGuide/net-dg-config-creds.html

When a constructor is called without explicit credentials it looks for "fallback" credentials located in one of the places noted in the article.

Let me know if this works and I want to narrow down and replicate your issue in order to resolve this quickly for you. -TEW

Steven-Mark-Ford commented 10 years ago

Thanks. I get the same error with the following configuration.

app.config:

<configuration>
 <appSettings>
    <add key="AWSProfileName" value="development"/>
    <add key="AWSProfilesLocation" value="E:\credentials"/>
  </appSettings>
</configuration>

E:\credentials: [development] aws_access_key_id = dummy aws_secret_access_key = dummy

In the interim I am using non-default constructor:

AWSCredentials credentials = new BasicAWSCredentials("Fake", "Fake");
client = new AmazonDynamoDBClient(credentials, new AmazonDynamoDBConfig(){ ServiceURL = "http://localhost:8000"});
tawalke commented 10 years ago

In your project are you referencing AWSSDK_Android or AWSSDK_XMOBILE.dll?

Steven-Mark-Ford commented 10 years ago

I'm using Xamarin Studio and I'm referencing AWSSDK_XMOBILE.dll @tawalke

tawalke commented 10 years ago

Steven: I am removing the default credentials to be on par with the Mobile SDK. Please leverage the AWS Credentials or Cognito when creating a DynamoDB Client.