I am using D7 and the code for services and REST found at https://github.com/kylebrowning/services.

That being said, I am unable to figure out where I would create an API Key.. can I get help on this? do I need an additional module?

Thanks!

CommentFileSizeAuthor
#8 rest_server_plist_7.x.zip153.03 KBkylebrowning

Comments

kylebrowning’s picture

Keys are no longer supported in 3.x look into using something like oauth.

pumpkinkid’s picture

So does that mean that the example application for the Drupal IOS SDK located (https://github.com/workhabitinc/drupal-ios-sdk-example) has to be modified to work with another authentication method?

kylebrowning’s picture

Also, you should be using the D7 code thats here on drupal.org

git clone --branch 7.x-3.x kylebrowning@git.drupal.org:project/services.git

pumpkinkid’s picture

I must be missing something basic then... The Sample app loads and builds correctly.. I have changed the DIOSConfig.h file to show:

define DRUPAL_API_KEY  @""
define DRUPAL_SERVICES_URL  @"http://10.1.1.172/iosdev/ios"
define DRUPAL_URL  @"http://10.1.1.172/iosdev"
define DRUPAL_DOMAIN @"10.1.1.172"

and I have checked to make sure http://10.1.1.172/iosdev/ios is the correct address (it does show a blank page).

kylebrowning’s picture

And whats your issue then?

pumpkinkid’s picture

oops... forgot to explain what I'm seeing in the simulator...

Basically I keep getting "HTTP/1.0 Not Acceptable: Missing required argument account" When trying to get the user with "1" in the field. I also keep getting similar errors on other methods...

kylebrowning’s picture

StatusFileSize
new153.03 KB

Hrmm, Make sure you are using the 7.x versino that exists on the website.

Which version of rest_server_plist are you using?

Try this one.

I just tested it and it worked fine, https://skitch.com/kylebrowning/r2a6j/ios-simulator-ipad-ios-4.3-8f190

pumpkinkid’s picture

I'm pretty sure that's the same version I was using, but I did replace it to make sure... still no go... Any permissions that could be causing this?

kylebrowning’s picture

I dont think so, Whats the timestam of your 7.x services.info?

pumpkinkid’s picture

2011/01/27 03:16:00

kylebrowning’s picture

pumpkinkid’s picture

Well it seems to be better now... It's now saying "Authentication Needed" so I take it I need to have an Authentication Module enabled... Any preference?

kylebrowning’s picture

Thats a permissoins issue, make sure anonymous can do a user get :P

Also try logging in with admin, although im not 100% sure if the 7.x-3.x version persists the login between tabs, an easy fix is close and restart the simulator after logging in.

pumpkinkid’s picture

I tried logging in and it does the same thing... even for Node Get... Stiil says "Authentication Needed"...

As for permissions, I am not sure about the "user get" but I did give it access to the profiles and enabled all the anonymous permissions for services... still no luck...

kylebrowning’s picture

Administer users

Give that perm to anonymous, when i turn that off, I get the same error, when i turn it back on it works.

pumpkinkid’s picture

Disregarding not feeling comfortable on a live app leaving Administer Users enabled for anonymous... I'm sorry to say that still did not fix it for me...

kylebrowning’s picture

Im not saying you need to do that for a live app. Im jsut trying to show you that its a permissions issue. If you want to make authenticated calls, thats easy to do, just login with a user that has that permission.

Heres a video showing it working, im not sure what else to say unless you expose your API so that I can make calls to it and try and debug the issue.

http://vimeo.com/22042580

pumpkinkid’s picture

I see what you mean... Ok... well other than the api.. is it possible that my settings on the app are bad?

kylebrowning’s picture

Authentication needed means your call is not passing permissions, So the calls to the API are working, you just need to figure out why it doesnt think you're authenticated. and no, the code in my app, all I changed was the Domain URL.

#define DRUPAL_API_KEY  @"4b2d7ef98d720386e0d2022842847404"
#define DRUPAL_SERVICES_URL  @"http://test/test"
#define DRUPAL_URL  @"http://test/"
#define DRUPAL_DOMAIN @"testing" 

Heres my endpoint export

$endpoint = new stdClass;
$endpoint->disabled = FALSE; /* Edit this to true to make a default endpoint disabled initially */
$endpoint->api_version = 3;
$endpoint->name = 'testing';
$endpoint->title = 'test';
$endpoint->server = 'rest_server';
$endpoint->path = 'test';
$endpoint->authentication = array();
$endpoint->resources = array(
  'comment' => array(
    'operations' => array(
      'create' => array(
        'enabled' => 1,
      ),
      'retrieve' => array(
        'enabled' => 1,
      ),
      'update' => array(
        'enabled' => 1,
      ),
      'delete' => array(
        'enabled' => 1,
      ),
    ),
    'actions' => array(
      'loadNodeComments' => array(
        'enabled' => 1,
      ),
      'countAll' => array(
        'enabled' => 1,
      ),
      'countNew' => array(
        'enabled' => 1,
      ),
    ),
  ),
  'file' => array(
    'operations' => array(
      'create' => array(
        'enabled' => 1,
      ),
      'retrieve' => array(
        'enabled' => 1,
      ),
      'delete' => array(
        'enabled' => 1,
      ),
    ),
  ),
  'node' => array(
    'operations' => array(
      'retrieve' => array(
        'enabled' => 1,
      ),
      'create' => array(
        'enabled' => 1,
      ),
      'update' => array(
        'enabled' => 1,
      ),
      'delete' => array(
        'enabled' => 1,
      ),
      'index' => array(
        'enabled' => 1,
      ),
    ),
    'relationships' => array(
      'files' => array(
        'enabled' => 1,
      ),
    ),
  ),
  'system' => array(
    'actions' => array(
      'connect' => array(
        'enabled' => 1,
      ),
      'get_variable' => array(
        'enabled' => 1,
      ),
      'set_variable' => array(
        'enabled' => 1,
      ),
    ),
  ),
  'taxonomy_term' => array(
    'operations' => array(
      'retrieve' => array(
        'enabled' => 1,
      ),
      'create' => array(
        'enabled' => 1,
      ),
      'update' => array(
        'enabled' => 1,
      ),
      'delete' => array(
        'enabled' => 1,
      ),
    ),
    'actions' => array(
      'selectNodes' => array(
        'enabled' => 1,
      ),
    ),
  ),
  'taxonomy_vocabulary' => array(
    'operations' => array(
      'retrieve' => array(
        'enabled' => 1,
      ),
      'create' => array(
        'enabled' => 1,
      ),
      'update' => array(
        'enabled' => 1,
      ),
      'delete' => array(
        'enabled' => 1,
      ),
    ),
    'actions' => array(
      'getTree' => array(
        'enabled' => 1,
      ),
    ),
  ),
  'user' => array(
    'operations' => array(
      'retrieve' => array(
        'enabled' => 1,
      ),
      'create' => array(
        'enabled' => 1,
      ),
      'update' => array(
        'enabled' => 1,
      ),
      'delete' => array(
        'enabled' => 1,
      ),
      'index' => array(
        'enabled' => 1,
      ),
    ),
    'actions' => array(
      'login' => array(
        'enabled' => 1,
      ),
      'logout' => array(
        'enabled' => 1,
      ),
    ),
  ),
);
$endpoint->debug = 0;
pumpkinkid’s picture

Ok... I imported your enpoint and it still says the same thing....

So how would we troubleshoot the authentication issue?

kylebrowning’s picture

Are you able to login with user.login?

pumpkinkid’s picture

I'm assuming you meant user/login... if so then yes... I just tried it again...

kylebrowning’s picture

Ok so when you login, and then try to do a node get, what happens? Does that user have the Access Content permission?

pumpkinkid’s picture

Right now the only user is user 1 so yes...

kylebrowning’s picture

So what happens when you do a node get?

pumpkinkid’s picture

The app just says the same thing... "Authentication Needed"...

Thing is, even not logged in to Drupal, I can see node 1...

kylebrowning’s picture

Not sure what to tell you. If you get the server up somewhere that I can point my App to it, I can see if its your server, or the app. But as it stands right now, its working for me, as you can clearly see in the video.

pumpkinkid’s picture

Ok, Well I'll let it be for today... Its almost quitting time, but I'll put it on an external site and give you access to it... nothing on it as you may have guessed, just trying to get that sample working.... lol

Thanks for all your help so far, I really appreciate it!

pumpkinkid’s picture

Have you by any chance tried using ips before? Wondering if that's the problem...

pumpkinkid’s picture

Nevermind, just set up my host file to work for www.internal.com and I'm still getting the error...

pumpkinkid’s picture

I kept looking and couldn't seen anything wrong on the Drupal end... so to be safe I completely deleted all my downloads and used your two links...

Not sure why... but it works now... thanks!

kylebrowning’s picture

Status: Active » Closed (fixed)
robotcake’s picture

I also have the same error: authentication needed, and I have donwloaded the most updated services and plist support, not sure why it happens... I can get node 1 without logging in as well.

Kunani’s picture

Same here. latest versions including the dev of services. Response status is a 401 Unauthorized: Missing required argument username. Other includes an ASIHTTP requesterrordomain code=3 "Authentication needed"

Communication with Drupal end seems to work with unauthenticated requests (requesting nodes).

Kunani’s picture

Okay found the error. Its actually in the DIOSuser.m file of the drupal-ios-sdk.

Inside loginWithUsername: the forKey:@"name" and forKey:@"pass" should be changed to "username" and "password" as shown below:

- (NSDictionary *) loginWithUsername:(NSString*)userName andPassword:(NSString*)password {
[self setMethod:@"user.login"];
[self setMethodUrl:@"user/login"];
[self addParam:userName forKey:@"username"];
[self addParam:password forKey:@"password"];
[self runMethod];
return [self connResult];
}

Hope this helps someone.

Also on a side note the ios-sdk project page looks like a typo, it says to updated DIOSConnect.h file with API keys and domain updates but its the DIOSConfig.h file

kylebrowning’s picture

Kunani, im not sure which version of the DRupal iOS SDK you are using, but in all the latest branches, its using username and password not name or pass, are you sure you have the latest code? This was fixed on Feb 7th, https://github.com/workhabitinc/drupal-ios-sdk/commit/139454fd8d1632ad9e...

robotcake’s picture

Yes I think we all have downloaded the tree with @"user/login" error, actually github offer 7.x-3.x-1.0b download in https://github.com/workhabitinc/drupal-ios-sdk/tree/ but that is really outdated (10 Nov 2010), I will try download the updated one in https://github.com/workhabitinc/drupal-ios-sdk/tree/7.x-3.x and see what will happen, thanks Kunani and kylebrowning!!

kylebrowning’s picture

Ahh Robotcake, thanks for pointing me to that, I forgot i tagged those releases. Release 1.1b is out!

MD3’s picture

Title: I can't figure out where to create an API Key » Updated GitHub Location:

Just so that everyone knows, Kyle has reorganized the git repo so, there are no longer 7.x-3x or 6.x-3.x etc. The latest version is here:
https://github.com/workhabitinc/drupal-ios-sdk/tree/

MD3’s picture

Title: Updated GitHub Location: » I can't figure out where to create an API Key - New GitHub Location
MD3’s picture

Title: I can't figure out where to create an API Key - New GitHub Location » I can't figure out where to create an API Key 3.x - Updated GitHub Location

Did not mean to update title!