iPhone APP using Services API with key authentication

Events happening in the community are now at Drupal community events on www.drupal.org.
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?)

Comments

As far as I can tell, you

john.moreau's picture

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

sweet thanks!

I'll reply if i get it working

Let me know if you need any

john.moreau's picture

Let me know if you need any sample code.

Examples are very welcome.

Liviooo's picture

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

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

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

Great! Do you have some working code?

AuthorizationManager reference?

glesage's picture

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's picture

And the RESTClient too btw..

Authentication working using Titanium Developer

chrsc's picture

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

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());
}

--
[develCuy](http://steemit.com/@develcuy) on steemit

DIOS SDK

scarer's picture

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's picture

Hi,

Did you connect to drupal using API key auth?

Thanks for sharing

Services

Group organizers

Group categories

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: