Modifications

Sauter à la navigation Sauter à la recherche
1 606 octets ajoutés ,  6 janvier 2015 à 07:21
aucun résumé de modification
Ligne 1 : Ligne 1 :  
{{Spark.IO-Could-API-NAV}}
 
{{Spark.IO-Could-API-NAV}}
 +
 +
{{traduction}}
    
== Authentification ==
 
== Authentification ==
Just because you've connected your Spark Core to the internet doesn't mean anyone else should have access to it. Permissions for controlling and communciating with your Spark Core are managed with OAuth2.
+
{{bloc-etroit|text=Just because you've connected your Spark Core to the internet doesn't mean anyone else should have access to it. Permissions for controlling and communciating with your Spark Core are managed with OAuth2.}}
    
  <nowiki># You type in your terminal
 
  <nowiki># You type in your terminal
Ligne 29 : Ligne 31 :     
In the future, you will be able to provision access to your Spark Core to other accounts and to third-party app developers; however, these features are not yet available.
 
In the future, you will be able to provision access to your Spark Core to other accounts and to third-party app developers; however, these features are not yet available.
 +
 +
=== Comment envoyer votre access_token ===
 +
There are three ways to send your access token in a request.
 +
 +
* In an HTTP Authorization header (always works)
 +
* In the URL query string (only works with GET requests)
 +
* In the request body (only works for POST & PUT when body is URL-encoded)
 +
 +
In these docs, you'll see example calls written using a terminal program called curl which may already be available on your machine.
 +
 +
Example commands will always start with '''curl'''.
 +
 +
<nowiki>curl -H "Authorization: Bearer 38bb7b318cc6898c80317decb34525844bc9db55"
 +
  https://...</nowiki>
 +
 +
To send a custom header using curl, use you the -H flag. The access token is called a "Bearer" token and goes in the standard HTTP Authorization header.
 +
 +
<nowiki>curl https://api.spark.io/v1/devices\?access_token=38bb7b318cc6898c80317decb34525844bc9db55</nowiki>
 +
 +
The query string is the part of the URL after a ? question mark. To send the access token in the query string just add access_token=38bb.... Because your terminal thinks the question mark is special, we escape it with a backslash.
 +
 +
<nowiki>curl -d access_token=38bb7b318cc6898c80317decb34525844bc9db55
 +
  https://...</nowiki>
 +
 +
The request body is how form contents are submitted on the web. Using curl, each parameter you send, including the access token is preceded by a -d flag. By default, if you add a -d flag, curl assumes that the request is a POST. If you need a different request type, you have to specifically say so with the -X flag, for example -X PUT.
 +
 +
=== Générer un nouvel access_token ===
 +
 +
{{traduction}}
 +
 
{{Spark.IO-Could-API-TRAILER}}
 
{{Spark.IO-Could-API-TRAILER}}
29 918

modifications

Menu de navigation