iPhone APP using Services API with key authentication

setvik's picture

Is it possible to use the Services API key authentication with an iPhone app?

I want to restrict Services API access to the app, but when i go to create a new KEY at http://[host]/admin/build/services/keys/add the one required field is "Allowed domain: *" with a description of "External domain allowed to use this key."

Does that mean that authentication keys only work for external applications that run on a single external server (i.e. is it not possible to use key authentication with an iphone app? or am i misunderstanding the field?)

Groups:
Login or register to post comments

As far as I can tell, you

john.moreau's picture
john.moreau - Wed, 2010-02-17 03:18

As far as I can tell, you generate a key with an "allowed" domain. as long as this domain name is used with this key to generate the sha256 hash and is passed over to the services module for a required service, you can make this domain name anything you want, such as "iPhone". Just make sure it is used consistently within your app. If you figure out a way to create the sha256 has value on the iPhone, I would be interested. I believe it would have something to do with the <CommonCrypto/CommonHMAC.h> library with a call to CCHmac, but I have not figured out how t do this yet.


sweet thanks! I'll reply if i

setvik's picture
setvik - Wed, 2010-02-17 04:00

sweet thanks!

I'll reply if i get it working


Let me know if you need any

john.moreau's picture
john.moreau - Wed, 2010-02-17 04:30

Let me know if you need any sample code.


Examples are very welcome.

Liviooo's picture
Liviooo - Fri, 2010-02-19 10:18

Examples are very welcome. I'm thinking of building an iPhone app for our website, so i could use some help here :-)


Example using OAuth

Hugo Wetterberg's picture
Hugo Wetterberg - Fri, 2010-02-19 10:43

Hi All,
Maybe this could be of some help: http://goodold.se/blog/tech/integrate-iphone-app-drupal

I'm also releasing the source for a iPhone app that integrates more fully with Drupal, creation of nodes and uploading of images et.c.: http://github.com/hugowetterberg/docuwalk-app. It uses the api-cleanup branch of my base library http://github.com/hugowetterberg/HBaseLibrary/tree/api-cleanup and the Drupal counterpart is here: http://github.com/hugowetterberg/docuwalk

As a release this is pretty unpolished, as I wasn't planning to release this yet, but maybe you can use it for inspiration.

/Hugo


PUSH Notification...

IrishGringo's picture
IrishGringo - Fri, 2010-02-19 14:24

this should probably go in its own thread, but What about code, practice, doing PUSH notification for iPhone from DRUPAL. I am working on some ideas myself.


Great! Do you have some

Hugo Wetterberg's picture
Hugo Wetterberg - Fri, 2010-02-19 14:32

Great! Do you have some working code?


AuthorizationManager reference?

glesage - Thu, 2011-09-15 17:13

Hi,

Great stuff, thanks for sharing.
I was wondering what are the available methods of AuthorizationManager, I can't find a reference anywhere...

PS: I am also currently working on a native app that needs to get data from drupal through services but I'm still debating which way to do it with in iOS (what authentification framework to use, what communication framework), which services server on drupal, etc...


RESTClient reference?

glesage - Thu, 2011-09-15 17:04

And the RESTClient too btw..


Authentication working using Titanium Developer

chrsc's picture
chrsc - Wed, 2010-06-09 19:17

Hi, I have an iPhone and Android application connecting to Drupal services using authentication. Its with Titanium Developer and is using javascript libraries, I'm sure some of the code can be used to write some native cocoa code.

http://blog.soniccode.com/php/drupal-connected-iphone-application-using-...

I used the js sha256 library you can find here:
http://point-at-infinity.org/jssha256/

Hope this helps someone :)

Chris


hash_mac sha256 in Titanium

develCuy's picture
develCuy - Mon, 2011-05-23 15:36

Services API requires a hash_mac with sha256, using the Javascript library above. Following function, based on jssja256, does the same as the PHP's hash_mac function:

function SHA256_hash_hmac(secret, key) {
  HMAC_SHA256_init(key);
  HMAC_SHA256_write(secret);
  return array_to_hex_string(HMAC_SHA256_finalize());
}

--
¡ Soy un drupalero latino !
Dear friend, I pray that you may enjoy good health and that all may go well with you, even as your soul is getting along well (3 John 1:2)


DIOS SDK

scarer - Fri, 2011-09-16 02:23

Hi there,

I've been successfully developing iPhone apps using Drupal with services, plist server and DIOS SDK. The DIOS SDK is a collection of classes with functions that allows you to use the services functions (i.e. node.get, file.get etc.)

I've been using it with iOS 5 too and have so far found no problems.

Hope that helps someone.

Cheers


API Key authentification?

glesage - Tue, 2011-10-18 20:49

Hi,

Did you connect to drupal using API key auth?

Thanks for sharing